On May 03, 2006, at 20:41 UTC, Jason Essington wrote: > > Try it! I would expect the compiler to tell you to take a hike (or > > at least, that you've passed an incorrect type on the badFruit call). > > Right, that's what I said ... the compiler whines when you try to > pass an apple as a fruit (very silly since an apple is a fruit)
No, it's perfectly happy when you pass an apple as a fruit. What you're trying to do in this example is pass a *reference to an apple* as a *reference to a fruit*. That's not valid, for reasons we've discussed. In fact, kudos for boiling the array example down to this more simple one, which really gets to the heart of the matter: a reference to a subclass type is NOT a reference to the superclass type. Arrays are just another way of passing around references. To do what you're suggesting for references, a reference would have to be a much bulkier (and slower) thing than it currently is. (Currently, it's most likely equivalent to an integer internally, because all type information is held by the compiler.) > Actually no. there is no looseness, java is very strict about types, > and will whine loudly if you do something illegal, like try to stuff > an orange into an array of apples. But only at run-time, apparently. RB complains at compile time. I consider that to be less loose, though it is sometimes inconvenient, as in the array case. Best, - Joe -- Joe Strout -- [EMAIL PROTECTED] Available for custom REALbasic programming or instruction. _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html>
