On 17 October 2013 13:45, Sebastian Krebs <
[email protected]> wrote:
While tinking about it: As assertions are a way to describe conditions,
that are valid _in every case_ (or else the application is unrecoverable
broken), it is somehow different from just "exeptional cases", that may be
recovered during runtime. Therefore I'd prefer "the hard with" with errors
and such. I think they are somehow comparable to compile-errors, but during
runtime. Or with a "LogicException", that isn't simply (and without side
effects) solveable by replacing the value of one variable with another one.
I tend to see it the same way. I think PHP's assert is derived from
C's assert, where ASSERT(3) says:
"... assert() prints an error message to standard error and terminates
the program by calling abort(3) if expression is false ..."
Where the important part is "terminates the program".
-- off topic --
What I'd love to see, though, would be conditional execution of the
assert block, i.e. if ASSERT_ACTIVE!=true, the expression wouldn't
even be evaluated. So it were usable with expressions instead of
strings in production code. I guess, accepting a callable as first
argument could more or less solve this wish now that we've got
closures...
Sorry Mike, you'll get this twice, just to keep everyone updated ...
By default, php's assert implementation will just generate a warning.
By default, this implementation throws an exception, resulting in abortion of execution if the exception is not handled ...
I'm still thinking about disabling compilation of the expression ... I'm not sure it's practical ...
Cheers