structs vs classes

Jim bitcirkel at yahoo.com
Sat Jan 29 05:43:40 PST 2011


I'm a bit troubled with the class/struct dichotomy. I would prefer them both to use the same keyword. Heap/stack allocation could be specified during instantiation instead. Why? Now you need to choose one over the other. Not even C++ has this limitation.

Think about containers for example, should they be classes or structs? Do you want them on the stack or on the heap?

I guess it's possible to define the entire container as a mixin now. That would let you have both heap and stack containers share definition, but generally I think that the dichotomy should be abolished.


More information about the Digitalmars-d mailing list