Csound Csound-dev Csound-tekno Search About

Re: if statement blocks

Date1999-02-24 08:34
FromJosep M Comajuncosas
SubjectRe: if statement blocks
Enough theory by now...Look at this example:
what the code should do:

if (...)  then do (...)
    else if (...) then do (...)
    else do (...)

(continue)


To do it with CsoundĀ“s current sintax you must do tricky jumps:

if (...) goto label1:goto label2
label1:
(...)
goto continue
label2:
if (...) goto label3:goto label4
label3:
(...)
goto continue
label4:
(...)
continue:
(...)

It works of course but it is very innelegant. And of course this makes sr=kr
necessary. Who prefers this sintax? As long as they are if... statements for variables
and conditional jumps we should have if... statements for blocks of code. And all sort
of conditionals should be available at a rate as well.


Josep M Comajuncosas




Dr J.Stevenson's research assistant wrote:

> >I don't see too much wrong with gotos as long as they are used correctly to
> I agree, but GOTOs  ( from experience of translating BASIC->C ) allow to much
>
> freedom to deviate from a rational ( structured ) program flow which is readable
>
> for others ( cleaning up spag code is much akin to programming in C64 ML IMHO


Date1999-02-24 19:47
FromAaron Isaksen
SubjectRe: if statement blocks
> Enough theory by now...Look at this example:

> if (...)  then do (...)
>     else if (...) then do (...)
>     else do (...)

I think that matlab style if statements are more applicable to the CSound
syntax:

if expression
  statements
elseif expression
  statements
else expression
  statements
end

That could probably be done with macros.

This uses the one-line-per-functional-statement semantics of Csound, and
reduces the number of keywords (don't need the 'do' statement and added
blocking necessary to do more than one statement inside a do block).

-Aaron