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: Charles Yeomans <yeomans at desuetude dot com>
Date: Thu, 20 Mar 2003 12:10:15 -0500

On Thursday, March 20, 2003, at 11:35  AM, Joseph J. Strout wrote:

At 10:12 AM -0500 3/20/03, Charles Yeomans wrote:

I have found a few glitches, though.  You cannot do the following.

Sub Foo(v as Variant)
Sub Foo(obj as Object)

Well sure, since a Variant is an Object, and so it's just like this case:

Now, you also cannot do the following.

Sub Foo( obj as Object)
Sub Foo(w as Window)

There you go.

But this makes sense, because here the overloading is ambiguous. But a Variant is not an Object

Here's your mistaken assumption (or perhaps it's documented incorrectly?).


I don't believe that Variant is a subclass of Object. If it were, then the code

dim v as Variant
dim obj as Object

v = self
obj = v

should assign the reference v to the reference obj, but it does not; instead it assigns the reference self to obj. And the code

dim v as Variant
dim obj as Object

v = 2
obj = v

causes a TypeMismatchException to be raised. In fact, this could be considered a bug, in the sense that one might expect the line

obj = v

to really mean

obj = v.ObjectValue

when the left-hand side is an Object or one of its many subclasses.




, not is an Object a Variant, so it seems to be that the first code snippet should compile.

(Bug ID = guqrdpth)

I assume you have no objection if we close this feedback record?

Indeed I do.


Next, suppose you define Sub Foo(v() as Variant). Then the following code compiles.

dim list(-1) as String
Test list

What is Test?  Did you mean to define Sub Test?

But the following code does not.

dim list(-1) as Object
Test list

I'm surprised either one compiles -- I didn't think we could convert an array of something else into an array of variants.


What I meant to write was that

dim list(-1) as Object
Foo list

compiles, but

dim list(-1) as String
Foo list

does not.

Charles Yeomans


---
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>