Do jMax have scoping ? I would like to simply say yes, and close the argument, but reality is a little bit more complex.
In the life of jMax, it arrived a time (around 1998) where it was clear that a generic mechanism to address global, shared data was needed in the language itself. Up to that moment, each time there was the need to share something between objects a dedicated solution had to be implemented. For example, the send and receive objects share a common, named control bus; the implementation of this control bus and the mechanism to share it is local to the objects, so, at the responsability of the object developer. Same thing for samples and sample readers, and for each kind of shared data.
So, back at that time, Norber Schnell and i designed a language extension that than i implemented, adding a new set of mechanisms, almost transparent to the object developers, to solve the problem once for all, and at the same time giving new functionalities to the language.
The basic idea is simple: the object init method take as argument the shared data itself, and not a name identifing the shared data or object is some way.
The textual argument written in the object box are an expression whose value are passed to the object initialisation.
So, instead of constant, any object can include an expression: for example,
int (1 + 1) is a perfectly legal object that is equivalent to
int 2. The code of the
int object do not see the expression, that is handled
by the jMax kernel, and pass just the result
2 to the object.
This is just an extension of the basic idea of Max like languages, where you can specify constants or variables (like $1 etc).
Next step was to generalise the idea of variable: any object can in jMax declare that is able to export some kind
of data that can be exported and shared; if an object export this data to be shared, it can be prefixed by a variable name, and the shared data can be referred in the patch using the
For example, you can have an object declared as
foo : int 3, and an other object
The int object bind its internal value to the name of
foo, and the second object can access it
using the symbolic variable
$foo. This is a complement to the patcher and abstraction arguments
in jMax patcher and abstraction arguments can also be explicitly named, like in
my-lowpass freq = 1000 q = 0.75).
This mechanism can be used to implements all the standard MAX objects like send and receive and a lot more. This mechanism support static scoping: the name of the variable is valid only in the patch where the variable is defined and in all its sub patches (but can, with a special syntax, be explicitly addressed from outside the patcher where it was defined).