Thereās no way to distinguish between a legitimate call to the preexisting method and a call to the wrong side of a name collision. Or, if youāre creating the event/environment, we donāt know how the object will be used. If youāre using it as an object prototype, then e.g. array
would be questionable as a member name (though the user might have handled it well ā the mere use of a method name as an object prototype key doesnāt inherently mean itās bad). But if itās not being used as a prototype, then there should be no restriction on the keys.
(
SynthDef(\notes, { |array = #[100, 200, 300, 400, 500], amp = 0.1, out|
var sig = SinOsc.ar(array).sum * (0.2 * amp);
Out.ar(out, sig)
}).add;
)
(
(instrument: \notes,
// this is called array, but it's not going to cause a bug
array: [{ exprand(200, 800) } ! 5],
amp: 0.7
).play;
)
One solution is to split object prototyping off into a separate class⦠which I did in the ddwProto quark. If youāre using a class called Proto
, then itās reasonable for the implementation to assume that you mean object prototyping. Then, in doesNotUnderstand
:
selector.isSetter.if({
selector = selector.asGetter;
(warnOnAssignment and: { super.respondsTo(selector) }).if({
"'%' is already a method for Proto. Conflicts may occur."
.format(selector).warn;
});
this.put(selector, args[0]);
result = this
}
(Old code, where I was still using a dumb way of writing if
ā¦)
But in Event / Environment, this should not be assumed. (So, one could argue that it wasnāt an ideal design decision to press Environment into service as an object prototype.)
This comes up from time to time⦠somebody gets confused about something and then thereās a proposal to detect the condition within the language and preemptively warn the user. I think we have to be very careful about that. Itās very easy to introduce bugs and degrade performance.
hjh