On May 03, 2006, at 22:27 UTC, Jason Essington wrote:

> > 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.
> 
> O.K. this is where the real difference lies ... in REALbasic, the  
> array is passes by reference (by default) however in java the  
> reference is passed by value (your head spinning yet?).

Hmm, I'm not sure I agree.  I'm not an expert in Java, but your description of 
RB isn't quite accurate.  The array reference is passed by value, but that's 
not the issue here anyway -- the issue is that an array *contains* object 
references.  I'm pretty sure the same would be true of a Java array.

> So the solution is simply to rewrite our ArrayCopy method to look  
> something like:
> 
> sub ArrayCopy(ByVal srcArray() as Object, ByVal destArray() as Object)

No, ByVal is always the default for parameters.  This is no different from what 
we had before.

>      destArray(i) = srcArray(i).clone()

And here is where the problem is, because destArray(i) is a reference of type 
Object (as is srcArray(i) of course).  So we can't pass in some array that 
doesn't contain references of type Object, but instead contains, say, 
references of type Date.

> So, my original suggestion is Possible in RB!!! you just have to  
> declare the parameters ByVal, and be sure that the destination array  
> is at least big enough when you pass it in, and everything works as  
> expected.

Alas, no.

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>

Reply via email to