You can look at casting as something you use to help the compiler when assigning values to variables that aren't obviously fit to contain them (like an int for a float variable of a Foo for a Bar variable) - that's what's common with copying floats and object references. For learning more about it you can look it up in a Java or C manual, though they'll contain a bit more than what's needed in ChucK (which doesn't have a lot of primitive types for starters). I'm a Java fan, so I'd go here: http://java.sun.com/docs/books/jls/third_edition/html/conversions.html#5.5

/Stefan


2009/12/12 Kassen <signal.automatique@gmail.com>
2009/12/12 mike clemow <gelfmuse@gmail.com>
Hi there,

2009/12/12 Stefan Blixt <stefan.blixt@gmail.com>:
> Hmm, you shouldn't have to cast from a subclass to its superclass, should
> you?

Well, this is my feeling as well.  A foo is-a spam.  The object
reference should work fine this way...


I agree. Back when I was starting out when classes and so on I did feel that this functionality was actually implied by the docs. I wonder whether that was intentional and that's actually meant to be how it should eventually work. This is one area where I do feel that the current docs need work. For one thing the "$" operator is only documented in how it casts from float to int, which is in and of itself a exception in that it loses information, unlike other forms of casting that need not lose information.

Kas.

_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users




--
Release me, insect, or I will destroy the Cosmos!