[chuck-users] Dealing with String objects?

Kassen signal.automatique at gmail.com
Mon Dec 24 07:39:27 EST 2012


On Sun, Dec 23, 2012 at 03:45:45PM -0500, Wolfgang Gil wrote:
> Hello chuckers
> 

Hey Wolfgang!

> I am looking for a reference to the 'string' object class in chuck. I am
> having a hard time trying to guess what methods are available for the
> class.

Sorry, but String is not a class, it is a primitive. Ok, it is a bit
unusual primitive that sometimes acts a bit differently from int,
float, dur, etc, but as far as I can remember those differences are
bugs. String should be a primitive with all of the advantages
(automatic instantiation) and all of the downsides (no member
functions) of those.

This is talking from the ChucK side, in the C++ source things might be
different; I never looked at that part of the source.


> I also recently came across with the StringTokenizer object but it seems to
> work only when the token is a white space. Is it possible to assign a
> different token to the object?

Sadly no, not that I know of. Do we need that?

> What gets printed is the object's type plus what I believe is a reference
> to memory that I am currently not interested in, separated by a colon (
> TriOsc:1001f36a0)
> 

Way cool! I've long wanted this. Could I suggest a way to get a array
of types in hierarchy? That way we could get something like;

["Object", "UGen", "StkInstrument", "Sitar"] //it's all of those

or;

["float"] //floats are clearly not objects, even is strings are weird.

That would be a great help when working with groups of objects that
have some things in common and not others. If, for examplle, we'd just
want a egg we could simply check whether the object is a "bird" and
thus would support .getEgg(), we might not be interested in whether it
has more detailed functions like .getBlueFeather() . In some cases
that might save a lot of checks and clean stuff up a lot. I don't like
big trees of IF's.

Currently that is mostly relevant for the StkInstrument series and the
Filter one, but I could see more sets like that and of course it would
make sense for our own class hierarchies.

> 
> Happy holidays!

You too! Don't let my modest proposals keep you away from this choice
reason to spend time with loved ones and food. There is probably some
rule against suggesting more work on Dec.24th to people with European
names. Sorry ;-)

Yours,
Kas.


More information about the chuck-users mailing list