It’s really just a matter of personal preference.
Generally, sclang has uniform function call syntax, so f(g)
is the same as g.f
. This means that you can either write wait(5)
or 5.wait
. This works with every method (including class methods!) so you can commit syntax crimes like read(Buffer, s, "sounds/a11wlk01.wav")
*)
When you combine this with the trailing block argument syntax, you get quite a few possible combinations:
if (b) { ... } { ... }
if(b, { ... }, { ... })
b.if({ ... }, { ... })
b.if { ... } { ... }
if (b, { ... }) { ... } // ugh!
b.if({ ... }) { ... } // ewww!
As for your question why people seem to prefer function call syntax (with trailing blocks) for certain methods like if
, fork
or loop
: I guess it’s just clearer to have the method at the beginning. If you put .fork
at the end of a long block, readers have to scroll all the way down before they know what’s going on. For if-statements in particular the function call style just looks more familiar to other languages with C-style syntax (C, C++, JavaScript, Java, C#, etc.)
*) Yes, that’s really the same as Buffer.read(s, "sounds/a11wlk01.wav")
!