Convenience methods

6 views
Skip to first unread message

James Surgenor

unread,
Mar 26, 2013, 6:31:26 PM3/26/13
to belfast...@googlegroups.com
Hi all,

This is going to be a completely random question that I should know that answer to, but still, SCDocs aren't helping.

I've been spending ages in other languages recently, and returning to SC is becoming pretty strange - most languages seem to have convenience methods (++ and += etc), and SC doesn't, but is there a reason for this or am I just being stupid?

(
i = 0;
i++;
i.postln;
)

and

(
a = 1;
a += 2;
a.postln;
)

both fail.


Are there a reasons for these not existing, or am I just forgetting the SC equivalent?

Apologies,
J

Dionysis Athinaios

unread,
Mar 26, 2013, 6:52:12 PM3/26/13
to James Surgenor
Hey :)

As far as I know SC does not have that. I think there might be a discussion of the reasons if you search the mailing list… Do let me know if I am wrong though!

That is not to say that SC does not have convenience methods though!! My impression is that in some cases there are actually too many of them and it can get a bit confusing…

best,

Dionysis

P.S: I am particularly against the .play convenience method that has only caused me problems when I was first learning SC… 

--
You received this message because you are subscribed to the Google Groups "Belfast SuperCollider User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to belfastcollid...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Miguel Negrão

unread,
Mar 26, 2013, 6:56:37 PM3/26/13
to belfast...@googlegroups.com

A 26/03/2013, às 22:31, James Surgenor escreveu:

> Hi all,
>
> This is going to be a completely random question that I should know that answer to, but still, SCDocs aren't helping.
>
> I've been spending ages in other languages recently, and returning to SC is becoming pretty strange - most languages seem to have convenience methods (++ and += etc), and SC doesn't, but is there a reason for this or am I just being stupid?

I don’t know if all imperative languages have ++ or not, but certainly none of the functional languages have them and SuperCollider is mostly imperative but with functional influences. Using those kind of operators is hardcore low level imperative style, SuperCollider generally operates at a higher level then that. For instance you’ll see them used a lot in c in for loops, but for loops are to be avoided in SuperCollider, instead one should use the collect method which corresponds to the classical ‘map’ function from functional programming, which uses anonymous functions something which is not possible to do in c. You should see using ++ and += a bit as writing assembly code, it’s not something you should want to be doing if you can avoid it (and you can).

best,
Miguel

Miguel Negrão

unread,
Mar 26, 2013, 7:37:11 PM3/26/13
to belfast...@googlegroups.com
Another reason, perhaps more objective, is that ++ is an operator and SuperCollider doesn’t really have operators (i.e. "operations which differ in the calling of syntax and/or the argument passing mode from the language's functions”[1]). In SuperCollider +, /, etc are just normal methods (lookup the definition of +). The ++ operation from c can’t really be implemented as a method of an object since it’s mutating a variable, so to implement it you would need to create a special syntax rule just for that which would complicate things unnecessarily.

[1]http://en.wikipedia.org/wiki/Operator_%28programming%29

best,
--
Miguel Negrão
http://www.friendlyvirus.org/miguelnegrao/






Cavan Fyans

unread,
Mar 27, 2013, 3:27:26 PM3/27/13
to belfast...@googlegroups.com
SARC undergrad lecture notes on patterns & timing (created by Michael Gurevich & myself)

09_Patterns.pdf
Reply all
Reply to author
Forward
0 new messages