On 06/14/2014 09:04 PM, Dmitry Olshansky wrote:
Recalling the previous discussion of throwing exception being costly, I thought the idiom of "pay as you go" is worth incorporating into the standard library.In brief: throw exception("CPU temperature is below", 2.5, "K"); vs throw new Exception(text("CPU temperature is below", 2.5, "K")); or: enforce(false, text("CPU temperature is below", 2.5, "K")); The benefit that the latter will only construct string if printing is indeed requested. Proof of concept: https://gist.github.com/DmitryOlshansky/59ec5953874bc1985ac5 The problem with it is that for some reason writeln of exception won't compile while thrown exception is printed just fine by the trace handler. Thoughts?
--- writeln(myException.info); --- Is it what you are looking for ?
