realbasic-nug
[Top] [All Lists]

Re: Call confusion

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Call confusion
From: Mars Saxman <mars at realsoftware dot com>
Date: Sat, 31 Dec 2005 13:50:57 -0800
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <BFDC5546 dot 77FD%Ed at Kleban dot com>

On Dec 31, 2005, at 1:33 PM, Ed Kleban wrote:

Ah, so there's no automatic casting to variant for calls... that actually
makes good sense.

That isn't quite how it works; the implicit conversion to variant applies to parameter passing just as it does to assignment. Still, it is the integer version of your method which will be called.

The overloading system works like this:
- Get a list of all the methods with the specified name.
- Remove any methods whose parameters are incompatible with the specified arguments.
- If only one method remains, call it.
- Otherwise, remove any methods whose parameter types are not an exact match for the arguments.
- If only one method remains, call it.
- Otherwise, report an error.

In your example, there are three versions of "foo". The version that accepts a string is rejected in step 2, since you can't assign an integer value to a string variable (there is no implicit conversion
from integer to string). Now there are two methods remaining, so we
move to step 4. The version of "foo" which accepts an integer is an exact match, so we keep it, but the version of "foo" which accepts a variant is not, so we reject it. Now, of course, the integer version of "foo" is the only one left on the list, so that's the one your call must refer to.

I don't think I understood your second example; the methods didn't have the same names, so I couldn't see how overloading would apply.

Mars Saxman
REAL Software
_______________________________________________
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>


<Prev in Thread] Current Thread [Next in Thread>