classes structs

David Currie curriedr at iinet.net.au
Fri Sep 14 15:19:07 PDT 2012


At the risk of appearing ignorant, I don't know everything about 
D.
However in D I have noticed the following.

It is a policy decision in D that a class is ALWAYS on the heap 
and passed
by REFERENCE. (I know there is a keyword to put a class object on 
the stack
but this is not facile and needing a workaround is poor language 
design).
This is effectively FORCED Java.
A D struct is on the stack and is NOT a class and has NO 
inheritance.

I have issues with this philosophy.

It seems FUNDAMENTAL to me that a programmer needs both stack and 
heap
objects and should KNOW when to use each and should ALWAYS have a 
choice.

ALL struct VARIABLES when declared are initialised to their .init 
value.
Just in case a programmer "forgets" to initialize them.
This is like using a sledgehammer instead of a scalpel.
Could you answer me WHY??
ALL classes when declared are instantiated on the heap
and their constructor called. Again I ask WHY??

Why can't the programmer have the freedom to build his own objects
when he wants to with the compiler advising of errors ?

Of course I have more to say about this but I need answers to 
these questions
to proceed.



More information about the Digitalmars-d mailing list