D - Constructors
- Philippe Mori (22/22) Sep 02 2003 Speaking of constructors, I would like to have some detail
- Walter (15/33) Sep 07 2003 Not sure what you mean here, but an object is first initialized with the
Speaking of constructors, I would like to have some detail on their working: - initialisation order (vs declaration) - what happen to member not explictly initialized. - when virtuality begins (if after full construction as it is the case in C++, then does with have a virtual pass afterwards). - does the data is pre-initialized (as in Delphi or C++ Builder VCL classes) - what happens when an exception occurs (from when the destructor is called, does partially constructed object are destroyed,...). How exception-safety works? How RAII works? I think that for constructor, the best thing would be to have some control of what get done at each important step... In particular, it would be interresting to be able to call virtually functions from the constructor (in the last pass). Also for constructor and assignment, does they are generated as in C++, the are not defined by default (as it should have been in C++) but can be defined (with a possible default implementation) or they are not intended to be copied as they are reference to one object and are kept alive until the last reference die.
Sep 02 2003
"Philippe Mori" <philippe_mori hotmail.com> wrote in message news:bj3him$12f2$1 digitaldaemon.com...Speaking of constructors, I would like to have some detail on their working: - initialisation order (vs declaration)Not sure what you mean here, but an object is first initialized with the static values of its members, and then the constructor is called on it.- what happen to member not explictly initialized.It is set to its default value, which is typically 0. All types have a default value.- when virtuality begins (if after full construction as it is the case in C++, then does with have a virtual pass afterwards).Virtuallity is there upon entry to the constructor.- does the data is pre-initialized (as in Delphi or C++ Builder VCL classes)Not sure what you mean, but the members all are set to their default values before the constructor is called.- what happens when an exception occurs (from when the destructor is called, does partially constructed object are destroyed,...). How exception-safety works? How RAII works?There aren't any partially constructed objects in D because they are preset to their default values. RAII works like it does in C++, an exception handler will execute to destroy it.Also for constructor and assignment, does they are generated as in C++, the are not defined by default (as it should have been in C++) but can be defined (with a possible default implementation) or they are not intended to be copied as they are reference to one object and are kept alive until the last reference die.There is no copy constructor or assignment operator overload in D. Just copy the references <g>. I also intend to add a virtual copy() function that can be used if one wants an actual copy.
Sep 07 2003