POV-Ray : Newsgroups : povray.off-topic : Generics annoyance : Re: Generics annoyance Server Time
4 Sep 2024 15:16:15 EDT (-0400)
  Re: Generics annoyance  
From: Darren New
Date: 14 Apr 2010 14:20:55
Message: <4bc60787$1@news.povray.org>
Warp wrote:
> Darren New <dne### [at] sanrrcom> 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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.