Re: parse errors when testing for undefined exceptions
| From: | Ron Korving | Date: | Wed, 01 Sep 2004 13:36:49 +0000 |
| Subject: | Re: parse errors when testing for undefined exceptions | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-12527@lists.php.net to get a copy of this message | ||
Okay, I agree with you on this one.
Very weird behaviour by the way.. I didn't know about this.
"Alan Knowles" <alan@akbkhome.com> schreef in bericht
news:4135CD4B.6040508@akbkhome.com...
> aghh.. - the previous example was crap
>
> The priciple it was try to make was that
>
> ....
> require_once 'MyException.php'
> throw MyException(....);
> ....
>
> then trying to catch MyException leads to a parse error when it's
> try()'d and not loaded. means we cant lazy load any Exceptions, and save
> file io/memory etc.
>
> Regards
> Alan
>
> Alan Knowles wrote:
>
> > This is a simple example of why making a parse error out of undefined
> > Exception types is going to be very problematic.
> >
> > function test($a) {
> >
> > if (!extension_exists('sqlite')) {
> > return;
> > }
> > try {
> > SQLite::query($a);
> > // parse error!!! - if we dont have sqlite, we dont have
> > SQLite exception!
> >
> > } catch(SQLite_Exception $e) {
> >
> > echo "problem with query";
> > return;
> > }
> > }
> >
> >
> > This has a big knock on effect that we can not lazy load Exception
> > definitions, even if they are only used in Exceptional situations.
> > (its pretty much the same issue as instanceof - forcing the loading of
> > code, that may never be used, except to test it's non-existance.)
> >
> > Regards
> > Alan
> >