This is a little above my head, but it seems that Scale.all is now empty. When I look at the class implementation, it is supposed to populate, but it doesn’t. Scale.directory has now extra spaces before the ‘keys’… Am I just drunk? I can download an old version of SC, but I don’t understand how to troubleshoot basic code that is in the initClass and that seems to disapear and used to behave. Any pointer welcome
The “basic code” for the Scale class hasn’t been changed since 2012. Seems this is extension/quark-related …
I did make a pr some time ago to remove that lil’ space in the .directory output. What “all” is supposed to do, I still don’t know…
I’m away from my pc at the moment (it’s late here), but I think this is the line that causes this. I think If you do Scale.all.parent you’d see all the entries.
@girthrub, I just approved your PR, looks like a clean fix! Don’t know if you want to wait for another review, but might be best to leave it for a couple of days so everyone gets to see it before merging.
Edit; and then I remember https://sc.dennis-scheiba.com/@dscheiba!!! Yes that is why Scale.all looks empty, it’s only printing the first in the hierarchy. Why it doesn’t print all by default - I don’t really know!?
.all seems to be used only in connection with .put.
If that is the case, would it make sense to incorporate this behaviour directly into .put instead?
Then .all might not need to be documented separately.
I can swear that Scale.all[\aeolian] was not working… I was also trying Scale.at[\aeolian] which wasn’t working. And Scale.all is still empty, so this is where I got stalled…
Scale.all.aeolian this doesn’t work because the dictionary isn’t marked as ‘known’.
Scale.at[\aeolian] this won’t work because it expands to Scale.at(nil).at(\aeolian) - you probably meant Scale.at(\aeolian). The error message here is not useful!
Scale[\aeolian] this does not work because it’s trying to create a collection Array[1, 2]. Imo, this is confusing syntax and shouldn’t exist, but it’s quite wide spread.
Scale.[\aeolian] this does work. Seems like a crude fix for the above case, just confusing in my opinion.
Scale.aeolian works, goes through *doesNotUnderstand.
I don’t know if there is anything that can be done to make Scale.all show the entire hierarchy, I stay away hierarchies and Event prototyping because it confuses me. @jamshark70 I believe you have some experience with this, anyway to get posting to show the entire hierarchy?
I tested the following code in SC 3.9.3, 3.12.2, and 3.13.0:
Scale.all
In all of these versions it returns:
-> IdentityDictionary[]
The relevant part of the Scale.sc file hasn’t been changed for the last 13 years.
Also, the corresponding section of the help document hasn’t been changed for the same period:
method::all
The scale repository, to which new scales can be added.
code::
Scale.all.put(\catastrophic, Scale([0, 0.01, 0.04, 11.2]));
Scale.at(\catastrophic); // access the scale
::
From a normal user’s perspective (at least in my case), the common usage is simply Scale.aeolian.
For users who prefer the more “orthodox” style recommended in the help documentation, Scale.at(\aeolian) would be the alternative.
So in practice, there seems to be little reason to write Scale.all[\aeolian].
My understanding is that .all mainly exists to allow adding new scales, as shown in the help file.
So when I asked whether .all is only meant to be used with .all.put, I was thinking that it might be clearer if .put internally handled .all.
However, if there are a significant number of users who actually rely on Scale.all[\aeolian] instead of Scale.aeolian or Scale.at(\aeolian), then of course such a change wouldn’t be appropriate.
Also, I don’t see any particular reason why the behaviour of Scale.all would need to change.
I’m accustomed to it now, but it was definitely a hurdle for me when I first encountered .all and .directory.
It did feel rather odd at the time.
Perhaps it would be better if the functionality of .all and .directory were made more intuitive.
I mean, .all seems to provide the functionality of .directory, and .directory seems to provide the functionality of .all.
Tricky… By design, parent and proto entries are intended to be lurking in the background, available for lookup but not subject to primary dictionary operations.
a = (a: 1).parent_((b: 2));
a.removeAt(\b);
a[\b];
-> 2
removeAt doesn’t apply to parent entries, but .at(\b) = [\b] does look into the parent.
In many cases, this is a good thing:
p = Pbind(\a, 1).asStream;
e = p.next(Event.default);
-> ('a': 1)
e.postcs // oh wait, I can't do this... (don't try to do this)
I had wanted to show that all the parent keys would be displayed, but there’s an 8-year-old unfixed bug about a circular reference in the event data structure… so, never mind.
I guess one solution could be to create a subclass of IdentityDictionary that maintains the hierarchical structure but which operates as if it were flat (removeAt, keysValuesDo, printOn etc. would all behave as though everything were stored on the same level). This would accurately model the different requirements: for most dictionaries, you want the hierarchy, but in this case (and likely some others) you want a flat list, regardless of the storage structure.
I guess one solution could be to create a subclass of IdentityDictionary…
Seems quite complicated just for printing. Unless it has other uses in the standard library.
I wonder if using parent here is even the correct solution? I guess it was done so the user can’t delete an existing scale, but they can override it with a new one, but why would you want to change the definition of a well established scale, its like changing the definition of ‘1’.
If it was redesigned, we could remove the public getter of all and have dedicated register and deregister methods Scale.register(\name, ...args to Scale.new ...) & Scale.deregister(\name).
The stated reason for the change was to “reduce garbage collection load,” but to be honest, I tend to agree with your point. SC’s general ethos for a long time has been, “we’re all grown-ups here, if you want to shoot yourself in the foot, at least in SC you won’t actually lose a toe.” The idea of protecting Scale definitions seems a bit contrary to that, and perhaps a bit over-engineered (while also being under-engineered, in that it didn’t consider the case of iterating over all scale definitions, for instance).
CPUs are pretty fast now. It may be better to drop the parent idea completely and just let it be a flat dictionary.