At 12:10 PM -0500 3/20/03, Charles Yeomans wrote:
I don't believe that Variant is a subclass of Object.
What, you think I'm making this stuff up? :) I'm telling you that it is.
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.
That's correct. Variants are special in that they overload various
operators to make them work, well, like Variants.
And the code
dim v as Variant
dim obj as Object
v = 2
obj = v
causes a TypeMismatchException to be raised.
Yep. The Variant class here is trying to stuff its value (an
integer) into the LHS of the assignment (an object), finding that it
can't do it, and raising the exception.
In fact, this could be considered a bug
One could, but we would disagree. It's acting exactly as it should.
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.
That is what it means. Or in general, the assignment always refers
to the Variant's value.
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.
Ah, OK, then this isn't a bug either, since an array of Variants is
indeed an array of Objects. So I trust you won't object if we close
that report too?
Best,
- Joe
--
,------------------------------------------------------------------.
| Joseph J. Strout REAL Software, Inc. |
| joe at realsoftware dot com http://www.realsoftware.com |
`------------------------------------------------------------------'
---
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>
.
|