From: Andy Glew
Subject: Error/exception handling (was: Re: Perl spontaneously jumps to other Perl code)
Date: 
Message-ID: <01bdc7c4$74c97880$82dcb58f@aglew2>
> Urgh. Blush. Embarassed.
> 
> Uncaught die exceptions in evals...

Okay, I realize that I have unconsciously had a C++, LISP, or even Ada exception handling model
in my mind, as opposed to Perl's eval model - which is a slight improvement on C's.

I.e. Perl by default "catches" and ignores any exception generated inside an eval (by die).
At the eval site, it is necessary to check the return value (for undef), and ยท@ (in case
it is legitimate for your eval to return undef, as happens to be in my design, since
I am using undef for SQL 'NULL' values), and then do further handling.

Unfortunately, I have lots of eval sites, since my evals need access to lexically scoped variables.
(If Perl had macros, I would use a macro...)

I.e. Perl is ignore by default inside eval,
optionally explicitly catch at eval site and arrange to propagate.


Q: is there anything that more closely approximates the C++/LISP/Ada strategy,
which I might summarize as
"don't ignore by default; propagate by default;
optionally explicitly catch at XXX site and optionally ignore at XXX site"?

{Where XXX site = catch/throw for LISP, or try/accept site for C==, and I forget what for Ada.}



I.e. is there a Perl exception mechanism which is conservative by default,
not optimistic by default?


----


(And, while we are at it, can anyone point me to any other exception/error handling models;
these are a longstanding interest of mine.)


---


Please respond by email,
in addition to replying to these newsgroups.