This is a repost of this :
Hello, I’m looking for help solving an issue as it involves the lang code and I am struggling to understand it.
Motivation
For some class
Test {
doesNotUnderstand{|...a|
a.postln
}
}
Test().foo(1, 2, bar: 4)
prints
WARNING: keyword arg 'bar' not found in call to ErTest:doesNotUnderstand
[ foo, 1, 2 ]
It would allow the creation of transparent wrapper classes if this would instead return
[foo, 1, 2, bar, 4]
meaning you could call code before and after all methods.
I’ve written a little Buffer
wrapper that tests to see if it has loaded on the server (and optional waits) before every method call, meaning the user never has to call s.sync again, it is completely transparent and works every where I have tested… except with named args method calls. This would be a huge simplification for the user.
Plan for Implementation
I think the problem lies here:
and that the issue is simply a matter of copying all the arguments over.
This section…
…copies only the args that match the current argument names.
Is it possible to copy the rest that do not match over, but placed at the end of the list so it doesn’t interfere with existing code?
I cannot seem to quite figure it out, is there any one who still understands this part of supercollider around?
There is one place where this will not work though, which is when the method arg name matches in doesNotUnderstand, e.g.,
Test {
doesNotUnderstand{|...a|
a.postln
}
}
Test().foo(1, 2, a: 4)
prints
4
The other option would be to create a doesNotUnderstandWithKeys in the class library. There is a cpp function doesNotUnderstandWithKeys
but no corresponding method in Object
- this is probably a bigger change though.
Thanks,
Jordan