On 15-06-2012 19:31, bearophile wrote:
Jonathan M Davis:

It's the fact that enforce is lazy which prevents inlining (which
really does
need to be fixed or enforce is going to continue to be a performance
problem).

Then my "solution" solves nothing. Thank you Jonathan.


However, this suggestion is clearly bad, because it's suggesting
turning an
exception into an assertion, which is _very_ broken thing to do.
Assertions
and exceptions are two _very_ different things and should be treated
as such.

enforce() sometimes is used as an assert you can't disable (as in
Nullable.get, I think). So maybe such cases are better handled
introducing two levels of asserts, "light asserts" and "strong asserts".

Bye,
bearophile

No, Jonathan's point is that enforce() can be used with both Errors and Exceptions. When used with Errors, we're talking about logic errors (effectively the same as an assert, with the exception that it isn't compiled out in release builds), while when we're talking about Exceptions, the error is recoverable. See for example some uses of enforce() in std.stdio.File.

--
Alex Rønne Petersen
[email protected]
http://lycus.org

Reply via email to