|
![](/i/fill.gif) |
Warp wrote:
> Darren New <dne### [at] san rr com> wrote:
>> That's certainly part of it, but you don't need to support multiple
>> inheritance in the same way C++ does it. Eiffel has multiple inheritance,
>> garbage collection, and O(1) virtual dispatch. (That last would probably be
>> quite difficult if you didn't compile everything at the same time, of course.)
>
> As I have mentioned before, you can cast an object pointer to an
> incompatible type assuming that:
Right. I'm not sure what that had to do with what I was saying.
I was trying to say that Eiffel holds only one pointer to any given object,
and that points to the start of the instance. This way, Eiffel gets simpler
GC. It also does multiple inheritance in fairly complex ways, and has an
efficient dispatch to handle it (i.e., no run-time lookups up the
inheritance chain).
I believe the mechanism relies on knowing at compile time what every class
in the system will be. You don't get the O(1) lookup in Eiffel if you don't
have the source to all the classes you inherit from when you compile the
class. You might not even get it if you don't have the source code for those
classes when you compile the callers, but I'm not sure.
> I wonder if Eiffel supports this as well.
Eiffel lets you cast up and down the heirarchy. All methods are semantically
virtual (even if the compiler optimizes them to direct jumps), so the fact
that you're casting up and down doesn't make it "invalid". You can't cast a
reference to an object to a type that isn't in that object's parent class
heirarchy.
There is one class called "ALL" that everyone inherits from. There is one
class called "NONE" that inherits from everyone, and which has only one
instance, called "Null". :-) So NULL can cast to any type, and any type can
cast to "ALL" (which serves as Object).
--
Darren New, San Diego CA, USA (PST)
Yes, we're traveling together,
but to different destinations.
Post a reply to this message
|
![](/i/fill.gif) |