Yes, I like this. Or a new type: Class.
As long as the method of comparison is safe (as safe as the typing system,
anyway), it makes tons of sense to do it.
If we used className() and it returned an array of strings, would we get the
entire hierarchy? I mean:
a[0]: Object
a[1]: UGen
a[2]: SinOsc
?
Mike
On Tue, Nov 9, 2010 at 12:46 PM, Michael Heuer
Right, that's why I proposed className().
A real instanceof keyword would return true for all of
(myUgen instanceof SinOsc.class) (myUgen instanceof UGen.class) (myUgen instanceof Object.class)
which would help with Kas' use case. How about
fun String className() fun String[] classNames()
?
mike clemow
: That bit of code would be great, if it worked. What I made did this: if( myUgen.typeOf() == "SinOsc" ) { // a string is ugly... myUgen $ SinOsc => SinOsc s; }
However, if the reserved word-- SinOsc --could be made equivalent to what was returned from .typeOf() or .className(), then it would be totally great. My hack was trivial, but this one wouldn't be. Mike On Tue, Nov 9, 2010 at 12:13 PM, Michael Heuer
wrote: mike clemow wrote:
Honestly, I've run into this a lot in the past and I'm familiar with this frustration. I even hacked my own version of chuck in which each
object
responded to a .typeOf(); message that returned a string representation (I know, it's ugly) of it's class name. I used this to make do smart casting, which I admit is still a huge compromise. I still think that each class name (reserved word) should be able to represent itself. Something to the tune of: if( myUgen.typeOf() == SinOsc ) { // seems reasonable, right? myUgen $ SinOsc => SinOsc s; }
I don't find that ugly, it's a cool hack. What if the method were called className()?
I vote for adding such to the git repo and push to get it added upstream.
michael _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- http://michaelclemow.com http://semiotech.org
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users