I’ve done some OOP coding in C++, Java, JavaScript and PHP, so I’m familiar with the basics of object-orientated programming.
All the SC documentation says SuperCollider is object-based. However, I only see mentions user-created classes in the context of SuperCollider extensions, but lots about creating and using functions.
Since SC is object-based, I assume functions are also objects. I don’t see anything in the tutorial docs I’ve seen so far about using functions as objects, however (ie treating a function declaration as a class definition, and creating instances, with their own encapsulated state, as one would do with OOP).
The only exception to this I see commonly is SynthDef, which seems to commonly be used in this way.
If, for example, I wanted to create, say, a kind of envelope, that I wanted to use in multiple places, passing different arguments, I’d obviously want to re-use the same code in some way.
The obvious way to do this would seem to be to create a function for it in the global scope, with a number of arguments and internal, local variables, and assign the function to a variable.
What would be the best way to proceed from there, though?
Would I just reuse the function by calling it, passing different values as arguments, functional programming style?
This would seem at odds with the object-based approach SC seems to encourage.
What would be the OOP way to approach this?
Sorry for the quite general question. I’m just trying to get my head around some basic concepts before I proceed too far down a coding dead-end.
Apologies also if my language is a bit on the “wooly” side. I’m entirely self-taught when it comes to writing code, so I’m not always able to be as precise as I’d like.