Re: my take on PHP 6, part 2
On Mon, 2014-02-17 at 09:31 +0000, Lester Caine wrote:
> While the discussion has also been opened up to include C++ which use
> 'exceptions' in normal process flow, IS it a given that we have to have
> exceptions at all? To my mind proper error handling should prevent the 'white
> screen' as the only way of handing things when everything has gone tits up? :(
Yes, we need Exceptions as Exceptions are the only good way to report
recoverable errors from constructors.
The reason C++ libraries like ICU allow disabling exceptions (if that's
the case, haven't researched) is that many projects disable exceptions
while compiling. Reason for that are
a) longterm users don't trust the compiler to create as efficient code
(fact is the code generated by modern C++ compilers typically is more
efficient than code with "classic" error handling, which includes
more branches)
b) Writing exception safe code in C++ isn't easy. Proper use of smart
pointers and RAII makes this viable. But many legacy libraries don't
follow those patterns. Contrary to PHP there is no native ref
counting / GC in C++ so non-exception-safe code leads to resource
leaks.
Both things aren't that kind of issues in PHP. Preventing a white page
for exceptions can be done with a error handler catching unhandled
exceptions.
johannes
Thread (25 messages)