D - Return Codes from Constructor
- Chris Hobbs <Chris_member pathlink.com> Apr 20 2004
- "Matthew" <matthew.hat stlsoft.dot.org> Apr 20 2004
I am unfamiliar with D but have read most of the user manual. I am disappointed to find that constructors cannot return an error code since I assume that they also cannot throw an exception (although I can't find this stated anywhere). In a telecommunications system, where the system cannot stop, it is essential for a constructor to be able to return a code to say "I didn't initialise properly, don't use me". This may result from the object being unable to get enough memory or other resources. Without a return code or exception (as in C++) it is necessary to define a public method bool createdOK(); which the creator must remember to call to see whether the object is in a zombiue state, having not really been created. This leads to all sorts of errors when people forget to call createdOK(); Chris Hobbs
Apr 20 2004
"Chris Hobbs" <Chris_member pathlink.com> wrote in message news:c642il$okl$1 digitaldaemon.com...I am unfamiliar with D but have read most of the user manual. I am disappointed to find that constructors cannot return an error code
assume that they also cannot throw an exception (although I can't find
stated anywhere).
They can.In a telecommunications system, where the system cannot stop, it is
for a constructor to be able to return a code to say "I didn't initialise properly, don't use me". This may result from the object being unable to
enough memory or other resources. Without a return code or exception (as
it is necessary to define a public method bool createdOK(); which the creator must remember to call to see whether the object is in a zombiue state, having not really been created. This leads to all sorts of
when people forget to call createdOK(); Chris Hobbs
Apr 20 2004








"Matthew" <matthew.hat stlsoft.dot.org>