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