This is an interesting digression: Is it OK, or not, for different implementations of the same method name to have very different signatures?
In many, many cases, we don’t mind at all. Both of these have the same method selector (ar
), but it would be nonsense to require all UGens to have the same arguments.
SinOsc.ar(freq, phase, mul, add)
RLPF.ar(in, freq, rq, mul, add)
In the case of plot, it’s also interesting to me that you have a clear expectation that name
should be front and center for all implementations – whereas I think I’ve never used that parameter at all! Based on my usage pattern, I could just as easily propose that name
should either not be there at all, or be the last parameter.
The class library itself doesn’t do much to break the tie:
(
~hasName = List.new;
~noName = List.new;
Class.allClasses.do { |class|
class.methods.do { |method|
if(method.name == \plot and: {
method.filenameSymbol.asString.contains("quark").not
}) {
if(method.argNames.tryPerform(\at, 1) == \name) {
~hasName.add(method)
} {
~noName.add(method)
}
}
};
};
"Plot methods with 'name' at the front:".postln;
~hasName.do { |method, i|
method.postln;
};
"\nPlot methods without 'name' at the front:".postln;
~noName.do { |method, i|
method.postln;
};
""
)
Plot methods with 'name' at the front:
ArrayedCollection:plot
Buffer:plot
Image:plot
Wavetable:plot
Plot methods without 'name' at the front:
BBlockerProgram:plot (this is in sc3-plugins, so let's exclude it)
Bus:plot
BusPlug:plot
Env:plot (nb: This one has 'name', but not at the front :-? )
Function:plot
The survey of main-library plot
methods turns up:
name
as leading parameter: 4
- No
name
parameter: 3
name
but later in the parameter list: 1
Bus
, BusPlug
and Function
plot all extract a short segment of a signal that will continue into the future – so the amount of time to plot is a crucial parameter, so it makes sense to put it up front. (IMO if it were { SinOsc.ar }.plot("SinOsc", 0.01)
, that would strike me funny – this would force the user either to type a string they don’t care about, or use a keyword argument, just to get to the really critical value = inconvenience.)
I can agree that this is a bit of a rough edge, though it hasn’t been a major annoyance historically. I guess the takeaway, when method arguments aren’t as you expect, might be to check the help or IDE method completion. (In another thread lately, I called into question my own tendency to think, “Something confused me, therefore it’s badly designed” – the second does not always follow from the first.)
hjh