Classes or stucts :: Newbie

Jonathan M Davis jmdavisProg at gmx.com
Mon Dec 20 10:24:40 PST 2010


On Monday, December 20, 2010 06:24:56 spir wrote:
> On Mon, 20 Dec 2010 03:11:49 -0800
> 
> Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> > Now, you could conceivably have a language where all of its objects were
> > actually pointers, but they were treated as value types. So,
> > 
> > B b;
> > A a = b;
> > 
> > would actually be declaring
> > 
> > B* b;
> > A* a = b;
> > 
> > underneath the hood, except that the assignment would do a deep copy and
> > allocate the appropriate meemory rather than just copying the pointer
> > like would happen in a language like C++ or D. Perhaps that's what
> > Oberon does. I have no idea. I have never heard of the language before,
> > let alone used it.
> 
> I don't know how Oberon works. But I'm sure that its records are plain
> values, _not_ "pointed" under the hood. And their methods all are virtual
> (they have a virtual method table). I have no more details, sorry.

Well, given C's memory model - which D uses - you can't do that. Oberon could 
use a different memory model and have some other way of doing it, but it won't 
work for D, so you'll never see structs with polymorphic behavior in D.

- Jonthan M Davis


More information about the Digitalmars-d-learn mailing list