[PD] jMax Phoenix

Bernardo Barros bernardobarros2 at gmail.com
Thu Sep 23 20:20:11 CEST 2010


I don't know the multiple syntaxes SuperCollider supports is a bad or
good thing (comparing to Python where there is only one syntax for
everything):

if (0.5.coin) {"Hey".postln} {"Ho!"};
OR
if (0.5.coin, {"Hey".postln}, {"Ho!"});

But since SC is object-oriented and "if" is a method of "boolean",
this also works and would be considered more consistent with the
language design:

(0.5.coin).if({"Hey".postln}, {"Ho!"})



2010/9/23 Mathieu Bouchard <matju at artengine.ca>:
> On Thu, 23 Sep 2010, IOhannes m zmoelnig wrote:
>
>> yes, but i believe this is because you are very used to C-like languages,
>> so you assume that expr's if looks like: "if <condition>, <then>, <else>".
>> you have been trained on that, probably since high school (and eventually
>> used it before) [*]. if you had been fed on perl, you might find other
>> things more easily to read.
>
> Perl also has a conditional-statement almost like C's. There are some
> differences. Its syntax is if (a) {b} else {c} instead of if (a) b; else c;
> because Perl has no separate concept of compound statement.
>
> And then also Perl has more different implicit conversions to bool than C
> has.
>
> The if-statement is remarkably uniform across different languages, in a way
> that the for-loop and the switch-statement aren't.
>
> The biggest difference you will see, is that some if-statements are actually
> if-expressions instead. This is the case with if(,,) in the [expr] class.
> This is also the case with a?b:c in C language. It's the case with
> if/then/else/end in Ruby and the if {} {} {} in Tcl.
>
> Perl is somewhat in-between because although you can't assign the result of
> an if-statement to a variable, you can return it from a function, but that's
> because Perl uses the value of the last executed statement as the default
> return value.
>
>  _______________________________________________________________________
> | Mathieu Bouchard ------------------------------ Villeray, Montréal, QC
> _______________________________________________
> Pd-list at iem.at mailing list
> UNSUBSCRIBE and account-management ->
> http://lists.puredata.info/listinfo/pd-list
>
>



More information about the Pd-list mailing list