[chuck-users] Dealing with String objects?

mike clemow michaelclemow at gmail.com
Mon Dec 24 15:03:17 EST 2012

Hey Wolfgang, Kas,

So, a few years ago I wanted the same thing for intelligent casting
purposes.  Instances of Object type respond to the method toString()
as well as typeOf(), a stubbed out method in Object source code with
no implementation.

My solution was modify the implementation of toString() to only return
the class name and inserted that into the stub for typeOf().

After recompilation, I could call typeOf() on instances (or instances
of subclasses of) Object and get a string representation of that
object's type.

I can be more specific about the change and the files involved when I
get back to my home after the holidays (Wednesday).

Hope this helps!  It's an easy change.


Sent from my Tracking Device.

On Dec 24, 2012, at 6:40 AM, Kassen <signal.automatique at gmail.com> wrote:

> 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.
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users

More information about the chuck-users mailing list