On Thursday, March 20, 2003, at 12:43 PM, Joseph J. Strout wrote:
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.
Your puckish reputation proceeds you, so who can be sure?
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.
We do disagree, because Liskov substitution suggests that I should be
able to use an Variant anywhere I can use an Object, but this is
clearly not the case. But Variants are intended to be a sort of
hybrid, so I'm not sure that I have any better suggestions. I've got
more code snippets, though.
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>
.
|