Hiding class pointers -- was it a good idea?
Gregor Richards
Richards at codu.org
Wed Aug 15 07:02:07 PDT 2007
OK, OK, I guess I should respond with an argument from computer science
as well :)
In the normal definition of Object Orientation, an object is a means of
storing a context in which operations can be performed. The abstraction
behind this (yay we're modeling the universe in code but realistically
we aren't yay) is irrelevant, as fundamentally OO is just a means of
storing and passing contexts. Because this is a context, it makes no
sense whatsoever to pass it around with duplication - duplicating
contexts is nonsense.
structs are sort of a hack for compatibility and/or optimization. They
are not contexts, they are means of creating more complicated values.
While a "Point" could be a struct, really being a more complicated
value, an "NPC" would always be a class, since it is a context.
The fact that this is inconsistent with C++ is irrelevant: D is more to
the spirit of good OO.
- Gregor Richards
More information about the Digitalmars-d
mailing list