[chuck-users] determining the type of an Object in code

mike clemow gelfmuse at gmail.com
Thu Feb 12 12:18:20 EST 2009


> ... You could also use a .isA() member function to implement hack-y
> generic container classes purely in ChucK code, which would be really cool
> to have.

Yes-Yes!

> Perhaps the solution here is adding a Object.typeName static method/static
> variable, which returns a string, allowing code like s.isA(SinOsc.typeName)
> to work.  That doesn't win any awards for terseness, but it seems like a
> good way to type-check this at compile-time without adding a new keyword.

I like this idea.  What about a compromise:

s.isA( SinOsc.type )

I think that reads better.  Also, while I'm more in favor of a static
member--for typing's sake--it seems to be the Chuckian way to
differentiate between .gain and .gain(), the latter being the accessor
methods that returns the value.  Hence,

s.isA( SinOsc.type() )

seems to be more in keeping with the rest of Chuck, stylistically
speaking.  I'll poke around for another static method on which to
model this one.

Cheers,
Mike


More information about the chuck-users mailing list