POV-Ray : Newsgroups : povray.off-topic : Generics annoyance : Re: Generics annoyance Server Time
4 Sep 2024 13:19:08 EDT (-0400)
  Re: Generics annoyance  
From: Warp
Date: 15 Apr 2010 05:39:17
Message: <4bc6dec4@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> >   That sounds like you would need several steps of indirection in order
> > to access a base class member using a derived class pointer. 

> Yep. Either that or, as I said, have the JIT do it the first time.

  JIT-compiling can't help if the *same* code has to handle objects of
different types.

> > And checks
> > for this would need to be done for *all* accesses, even in situations where
> > there's no inheritance at all (because the code which tries to access the
> > object through the pointer cannot know if the object it was given was a
> > derived object or not, without always checking).

> Well, what I meant was that if you have Alpha::Hello() and Beta::There() and 
> you create a Gamma that inherits from both, you could actually copy the code 
> of Alpha::Hello and Beta::There into Gamma, adjusting the offsets of local 
> variables as you go. With clever vtable layout, you could have Alpha::Hello 
> and Gamma::Hello at the same offset in the vtable, and the same with 
> Beta:There and Gamma::There.  (That's what Meyer invented for Eiffel.)

  Wouldn't that be difficult to do if Alpha and Beta are precompiled?

> >   Well, the Java people added their crippled version of templates to the
> > language regardless of all the arguments why templates are bad, so maybe
> > there's hope that MI will also be added, regardless of all the arguments
> > why it's bad.

> Well, not templates as such. Nothing near as useful. Just generics, using 
> the same awful C++ syntax. :-)

  That's why I said "crippled version of templates".

-- 
                                                          - Warp


Post a reply to this message

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