List of Phobos functions that allocate memory?

Marco Leise Marco.Leise at gmx.de
Sat Feb 8 21:00:51 PST 2014


Am Sat, 08 Feb 2014 14:01:12 -0800
schrieb Walter Bright <newshound2 at digitalmars.com>:

> On 2/7/2014 8:40 AM, Dmitry Olshansky wrote:
> > Meh. If exceptions are such a liability we'd better make them (much) faster.
> 
> They can be made faster by slowing down non-exception code.
> 
> This has been debated at length in the C++ community, and the generally accepted 
> answer is that non-exception code performance is preferred and exception 
> performance is thrown under the bus in order to achieve it.
> 
> I think it's quite a reasonable conclusion.

https://yourlogicalfallacyis.com/black-or-white

The reasons for slow exceptions in D could be the generation
of stack trace strings or the garbage collector instead of
inherent trade offs to keep the successful code path fast.

And static allocation isn't an exactly appealing option...

  throw staticException ? staticException : (staticException =
  new SomethingException("Don't do this at home kids!"));

and practically out of question when you need to chain
exceptions and your call stack could contain this line of code
more than once, resulting in infinite loops in exception
chains as a new bug type in D, that is fixed by writing:

  catch (Exception e) {
      throw (staticException ? (e.linksTo(staticException) ? staticException.dupThenWrap(e) : staticException) : (staticException = new SomethingException("Don't do this at home kids!"));
  }

-- 
Marco



More information about the Digitalmars-d mailing list