On Thu, 2003-03-06 at 16:41, Linus Torvalds wrote: > On Thu, 6 Mar 2003, Ian Molton wrote: > > > > foo=malloc(sizeof(thing)) > > if(!foo) > > ... > > Well, the advantage of "new" is that it will run all the constructors etc > automatically, so it's potentially a simpler allocation than C. > > If your point is that it's certainly no more complex than the C sequence, > then you're obviously right ;)
The problem if you have an "operator new" implementation that doesn't throw is that it becomes painful to deal with failure in constructors (which are a pain in the ass anyway, but at least _can_ be dealt properly with exceptions). The workaround would have to have that operator new basically try/catch around the constuctor chain call (in place new) and return NULl when that fails, though it doesn't provide very expressive error code. I tend to understand why Apple dumped the constructor approach as much as possible and added a separate init() method to all their classes Ben. ------------------------------------------------------- This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger for complex code. Debugging C/C++ programs can leave you feeling lost and disoriented. TotalView can help you find your way. Available on major UNIX and Linux platforms. Try it free. www.etnus.com _______________________________________________ Dri-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dri-devel