realbasic-nug
[Top] [All Lists]

Re: Overloading in RB 5

To: REALbasic Network Users Group <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Overloading in RB 5
From: Mars Saxman <mars at realsoftware dot com>
Date: Thu, 20 Mar 2003 08:49:35 -0800
yeomans at desuetude dot com wrote:

> I have found a few glitches, though.  You cannot do the following.
> 
> Sub Foo(v as Variant)
> Sub Foo(obj as Object)
> 
> Now, you also cannot do the following.
> 
> Sub Foo( obj as Object)
> Sub Foo(w as Window)
>
> But this makes sense, because here the overloading is ambiguous.

That's true, but you can disambiguate it by casting your argument to
"Window". If the argument types match one method's parameters exactly, the
compiler selects that method whether there are other legal options or not.
(This is copied from the old compiler's behaviour.)

> Next, suppose you define Sub Foo(v() as Variant).  Then the following
> code compiles.
> 
> dim list(-1) as String
> Test list

Oh, ouch. That's certainly a bug. I'm sure you will get either a crash or
some other nasty behaviour if you actually try to use that array of variants
inside Foo.

Mars Saxman
REAL Software


---
A searchable archive of this list is available at:
<http://support.realsoftware.com/listarchives/search.php>

Unsubscribe:
<mailto:realbasic-nug-off at lists dot realsoftware dot com>

Subscribe to the digest: 
<mailto:realbasic-nug-digest at lists dot realsoftware dot com>
.


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