Interface question

Charles D Hixson charleshixsn at earthlink.net
Wed Aug 30 11:04:39 PDT 2006


xs0 wrote:
> 
>> I guess what I'm going to need to do is derive everything from a 
>> common ancestral class...and that means that the derived classes CAN'T 
>> descend from anything else, *sigh*.  The common ancestor will need to 
>> be a totally abstract class, so I thought an interface would be a 
>> better choice, but it looks like there's no way to make it 
>> work...because they've all got to implement a common constructor type, 
>> and the compiler has to KNOW that they do so.
> 
> Hmm.. why exactly do you need a common constructor type? When you create 
> an object, you must know its exact type (and constructors) anyway, so 
> how does it matter?
> 
> 
> xs0
I think maybe you're right.  If so, then I probably can't do 
what I want to do in D.  I'd been thinking that if I just 
worked ahead I'd be able to solve the problem of "somehow" 
using the thing that I'd created, if I could only create it. 
And I could refer to it from the ancestral reference.  But I 
hadn't been able to figure out the details, so I was just 
trying to work my way forwards.  But maybe I can't do it at all.

(Well, this isn't literally true, of course.  I could always 
define everything in terms of a Vector of bytes.  But in so 
doing I give up most of what makes Computer Languages 
different from assembler.)

I guess that means that it's back to Python.  At least I can 
drop into Pyrex when I hit places that are performance 
bottlenecks.  Or even into C.  (I may truly dislike C with 
it's wild use of pointers, but it *is* possible.  And it's 
about the same speed as D. [I don't really believe that 
shootout that says that D is faster.  How *can* it be?])



More information about the Digitalmars-d-learn mailing list