<div dir="ltr"><p style="margin:0px;font-size:12px;font-family:Helvetica">Since a lot of stuff in ChucK owes to Java, and java.lang.String is a class like any other, with the unique extra privilege of having its own kind of constructor using double quotes, I had a hunch that something similar may be the case here. Here's some experimental code:</p>

<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">-----------------------------------------</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">"oy" => string c;</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica"><<< "tjo", c.length() >>>;</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica"><<< "tjo", c.upper() >>>;</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica"><<< "tjo", c.lower() >>>;</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">class Y extends string {</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">        fun string toString() {</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">                return "gabber";</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">        }</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">}</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">"jungle" => string o;</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica"><<< "I like " + o.toString() >>>;</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">new Y => o;</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">Y y;</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica"><<< "I also like " + o.toString() >>>;</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica"><<< "But why not " + y.toString() >>>;</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">-----------------------------------------</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">At the top you can see the string type has at least three methods (length, upper and lower). Below you can see that you can make a subclass of string (trying the same thing with int causes an error).</p>

<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">Below that I tried to override toString() and use it, which doesn't quite work (the second last line will not print the word "gabber", but the last will. The compiler complains if I change the return type from string to Object though, so it's clearly seeing it as an override of string's toString().</p>

<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">It's also interesting that if I add this line:</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica"><<< "Charred at ", o.charAt(0) >>>;</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">I get this message</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">[<a href="http://test.ck">test.ck</a>]:line(27): class 'string' has no member 'charAt'</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">(note the word 'class'). While this:</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">7 => int x;</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica"><<< "Charred at ", x.charAt(0) >>>;</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">yields:</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">[<a href="http://test.ck">test.ck</a>]:line(27): type 'int' does not have members - invalid use in dot expression</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">So while they may not have a whole lot of use as such, I'd say that strings can be viewed as classes, and more crucially they are objects - something complex that ChucK refers to rather than uses directly - a bit like arrays:</p>

<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">int a[1];</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica"><<< "Charred at ", a.charAt(0) >>>;</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">----------v-------------</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">[<a href="http://test.ck">test.ck</a>]:line(31): class 'int[]' has no member 'charAt'</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;font-family:Helvetica">I found the reference to upper() and lower() here after googling around:</p>
<p style="margin:0px;font-size:12px;font-family:Helvetica"><a href="https://lists.cs.princeton.edu/pipermail/chuck-dev/2012-March/000435.html">https://lists.cs.princeton.edu/pipermail/chuck-dev/2012-March/000435.html</a></p>

<p style="margin:0px;font-size:12px;font-family:Helvetica;min-height:14px"><br></p></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Dec 25, 2012 at 7:59 PM, Wolfgang Gil <span dir="ltr"><<a href="mailto:wolfgang.gil@gmail.com" target="_blank">wolfgang.gil@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><font face="arial, helvetica, sans-serif">Hey,</font><div><font face="arial, helvetica, sans-serif"><br></font></div><div>
<font face="arial, helvetica, sans-serif">Mike, your suggestion sounds great. I look forward to hearing more about it.</font></div>
<div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Kassen, thanks for the info. My german name was given to me in Venezuela, where I was born. I have not german family whatsoever. I am half venezuelan, half spanish, currently leaving in NY. Here I met my <span style="font-size:13px;line-height:19px">fiancée, a japanese lady I have been living with for the last four years. I use more chopsticks than fork and knife these days</span></font></div>

<div><span style="color:rgb(34,34,34);line-height:16px;font-family:arial,sans-serif"><em style="font-weight:bold;font-style:normal;color:rgb(0,0,0)"><br></em></span></div><div><span style="color:rgb(34,34,34);line-height:16px;font-family:arial,sans-serif"><em style="font-style:normal;color:rgb(0,0,0)">C'est la vie ;)</em></span><div>
<div class="h5"><br>
<br><div class="gmail_quote">On Mon, Dec 24, 2012 at 3:03 PM, mike clemow <span dir="ltr"><<a href="mailto:michaelclemow@gmail.com" target="_blank">michaelclemow@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hey Wolfgang, Kas,<br>
<br>
So, a few years ago I wanted the same thing for intelligent casting<br>
purposes.  Instances of Object type respond to the method toString()<br>
as well as typeOf(), a stubbed out method in Object source code with<br>
no implementation.<br>
<br>
My solution was modify the implementation of toString() to only return<br>
the class name and inserted that into the stub for typeOf().<br>
<br>
After recompilation, I could call typeOf() on instances (or instances<br>
of subclasses of) Object and get a string representation of that<br>
object's type.<br>
<br>
I can be more specific about the change and the files involved when I<br>
get back to my home after the holidays (Wednesday).<br>
<br>
Hope this helps!  It's an easy change.<br>
<br>
-mike<br>
<br>
//--<br>
Sent from my Tracking Device.<br>
--//<br>
<div><div><br>
On Dec 24, 2012, at 6:40 AM, Kassen <<a href="mailto:signal.automatique@gmail.com" target="_blank">signal.automatique@gmail.com</a>> wrote:<br>
<br>
> On Sun, Dec 23, 2012 at 03:45:45PM -0500, Wolfgang Gil wrote:<br>
>> Hello chuckers<br>
>><br>
><br>
> Hey Wolfgang!<br>
><br>
>> I am looking for a reference to the 'string' object class in chuck. I am<br>
>> having a hard time trying to guess what methods are available for the<br>
>> class.<br>
><br>
> Sorry, but String is not a class, it is a primitive. Ok, it is a bit<br>
> unusual primitive that sometimes acts a bit differently from int,<br>
> float, dur, etc, but as far as I can remember those differences are<br>
> bugs. String should be a primitive with all of the advantages<br>
> (automatic instantiation) and all of the downsides (no member<br>
> functions) of those.<br>
><br>
> This is talking from the ChucK side, in the C++ source things might be<br>
> different; I never looked at that part of the source.<br>
><br>
><br>
>> I also recently came across with the StringTokenizer object but it seems to<br>
>> work only when the token is a white space. Is it possible to assign a<br>
>> different token to the object?<br>
><br>
> Sadly no, not that I know of. Do we need that?<br>
><br>
>> What gets printed is the object's type plus what I believe is a reference<br>
>> to memory that I am currently not interested in, separated by a colon (<br>
>> TriOsc:1001f36a0)<br>
>><br>
><br>
> Way cool! I've long wanted this. Could I suggest a way to get a array<br>
> of types in hierarchy? That way we could get something like;<br>
><br>
> ["Object", "UGen", "StkInstrument", "Sitar"] //it's all of those<br>
><br>
> or;<br>
><br>
> ["float"] //floats are clearly not objects, even is strings are weird.<br>
><br>
> That would be a great help when working with groups of objects that<br>
> have some things in common and not others. If, for examplle, we'd just<br>
> want a egg we could simply check whether the object is a "bird" and<br>
> thus would support .getEgg(), we might not be interested in whether it<br>
> has more detailed functions like .getBlueFeather() . In some cases<br>
> that might save a lot of checks and clean stuff up a lot. I don't like<br>
> big trees of IF's.<br>
><br>
> Currently that is mostly relevant for the StkInstrument series and the<br>
> Filter one, but I could see more sets like that and of course it would<br>
> make sense for our own class hierarchies.<br>
><br>
>><br>
>> Happy holidays!<br>
><br>
> You too! Don't let my modest proposals keep you away from this choice<br>
> reason to spend time with loved ones and food. There is probably some<br>
> rule against suggesting more work on Dec.24th to people with European<br>
> names. Sorry ;-)<br>
><br>
> Yours,<br>
> Kas.<br>
> _______________________________________________<br>
> chuck-users mailing list<br>
> <a href="mailto:chuck-users@lists.cs.princeton.edu" target="_blank">chuck-users@lists.cs.princeton.edu</a><br>
> <a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
_______________________________________________<br>
chuck-users mailing list<br>
<a href="mailto:chuck-users@lists.cs.princeton.edu" target="_blank">chuck-users@lists.cs.princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br>

<p><a href="http://www.wolfganggil.com/about" target="_blank">http://www.wolfganggil.com</a></p>





</font></span></div>
<br>_______________________________________________<br>
chuck-users mailing list<br>
<a href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Release me, insect, or I will destroy the Cosmos!
</div>