[PD] jMax Phoenix

Mathieu Bouchard matju at artengine.ca
Fri Oct 8 17:11:21 CEST 2010


On Thu, 23 Sep 2010, Bernardo Barros wrote:

> 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!"})

To complete what we were saying, even though there's a lot in common 
between SC and Ruby, conditionals are completely different over there, and 
there are nine syntaxes for conditionals, NOT including a method of 
boolean (because Ruby doesn't have this feature).

I forgot to say last time (and that's probably what IOhannes was referring 
to) that in Perl and Ruby, the operators && || "and" "or" have been 
recycled into conditionals in Perl and Ruby. Then there are also the 
reverse conditionals "if" and "unless". those statements are all 
equivalent in Ruby :

   if debug then post("problem") end
   unless not debug then post("problem") end
   post("problem") if debug
   post("problem") unless not debug
   debug and post("problem")
   debug && post("problem")
   not debug or post("problem")
   !debug || post("problem")
   debug ? post("problem") : nil

which is almost the same deal as in Perl except Ruby's regular "if" 
statement is actually an expression.

"and"/"or" and "&&"/"||" aren't just aliases, because they also have 
different priorities.

  _______________________________________________________________________
| Mathieu Bouchard ------------------------------ Villeray, Montréal, QC


More information about the Pd-list mailing list