I think probably… you can’t.
It would be handy in my use case since I typically use the interpreter variables to hold useful things, for example g
is always an Event
containing Groups
.
I think probably… you can’t.
It would be handy in my use case since I typically use the interpreter variables to hold useful things, for example g
is always an Event
containing Groups
.
It’s not an ideal design but you can reach them: (not at my computer but) try thisProcess.interpreter.g
.
hjh
Don’t, at some point it will break and fixing that will be really hard!
Use Library
.
Thanks both for your guidance. I’m aware that using global variables is generally regarded as an antipattern.
I am interested in alternatives, but they have to be convenient. Library
looks like an awful lot of typing to access things I use all the time.
I mean, in the setup class I could do:
Library.put(\groups,());
And then in my .scd files I could do this:
g = Library.at(\groups);
But I’m not sure I’ve made anything any better.
Yes you have!
If, later on, you made the very reasonable mistake of assigning something to g
thinking it was a local variable, like this…
(
var f = 1;
// blah blah blah...
g = 2;
)
…you will have just deleted your groups.
Interpreter values always have a value (nil), so you won’t ever get an error if you forget to assign the Event
to g, the code will just carry on as long as possible, leading to very hard error messages.
Its just going to cause you headaches later.
You don’t edit class files all the much, saving a few characters here isn’t worth it, besides, that is what functions are for groups { ^ Library.at(\groups) }
.
Assigning the Library
entry to a local variable (even an interpreter variable) to save characters is absolutely
fine.
Okay, I thank you for your patient explanation and will take your advice.