Why there are no 'physical' object variables (only references)?

Steve Horne stephenwantshornenospam100 at aol.com
Wed Sep 13 02:04:59 PDT 2006


On Wed, 13 Sep 2006 06:33:19 +1000, Reiner Pope
<reiner.pope at REMOVE.THIS.gmail.com> wrote:

>interface Foo
<SNIP>
>struct Bar : Foo
<SNIP>
>void calc(Foo f) { ... }
>
>How can calc know the type of every struct it is passed unless a 
>separate version of calc is generated for every type (in which case it 
>is just a template)?

Compiler generated proxy object, containing a vtable and a pointer to
the struct.

To pass the struct as an interface, you need some kind of reference
anyway. You can't just pass the whole struct. A reference to a proxy
object would make at least some sense.

Mind you, it's very dodgy, to say the least. I have argued for struct
inheritance, but this is not the kind of inheritance I want. I still
want structs to be data, not reference-free objects.

-- 
Remove 'wants' and 'nospam' from e-mail.



More information about the Digitalmars-d mailing list