On Mon, 2003-03-31 at 10:53, Zeev Suraski wrote:
> At 11:35 31/03/2003, Per Lundberg wrote:
> >On Sat, 2003-03-29 at 12:59, Zeev Suraski wrote:
> > > Writing exception-driven applications is extremely discouraged.
> >What is the rationale behind this?
> (a) This is very much the case for all languages that have 
> exceptions.  Exception handling is *slow*.  Coding exception-driven apps in 
> Java and C++ is a bad idea too.  Exceptions were designed to handle errors, 
> and not provide some nifty way of shifting control from one place to another.

I agree.  But is it a problem if error handling is slow?  I mean, 
errors are not the normal flow of the application, and need not be
optimized as such.

If it slows down the code too much even when the exception is not
thrown, I can agree with your reasoning.  And yes, there are certainly
cases where exceptions are being used when not really neccessary.

> (b) In PHP, exception handling results in memory leaks.  Like all leaks in 
> PHP, they'd be taken care of at the end of the request.  Until the end of 
> the request, however, certain chunks of memory will not be reclaimed.

This could turn out to be a big problem for people developing non-web
applications with PHP, applications running for a long time.  Why do
exception handling leak?  Would it be impossible/very hard to fix this
behavior?


Another thing that just hit me: it would be incredibly useful to do like
this:

try {
  eval($string);
}
catch (FatalErrorException $e) {
  // handle the error.
}

Imagine the scenario with a standalone application loading in some
script from the user's home directory.  It would really be very bad if
the application just died here; it would limit the usability of the Zend
Engine for such an application a lot.

Yes, eval could be changed to return an error code, but that would
slightly break BC since the eval is to return the return()-value from
the eval()'ed code.

Do you agree that exceptions would be very convenient for this kind of
code/situation?
-- 
Best regards,

Per Lundberg / Capio ApS
Phone: +46-18-4186040
Fax: +46-18-4186049
Web: http://www.capio.com

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to