Zsh Mailing List Archive
Messages sorted by:
Re: Exception handling and "trap" vs. TRAPNAL()
- X-seq: zsh-workers 21805
- From: DervishD <zsh@xxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Exception handling and "trap" vs. TRAPNAL()
- Date: Mon, 3 Oct 2005 01:00:27 +0200
- Cc: zsh-workers@xxxxxxxxxx
- In-reply-to: <1051002195518.ZM2163@xxxxxxxxxxxxxxxxxxxxxxx>
- Mail-followup-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, zsh-workers@xxxxxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- Organization: DervishD
- References: <20050929200741.GA1156@DervishD> <20050930124130.45eb0463.pws@xxxxxxx> <20051001153756.GA12183@DervishD> <1051001183818.ZM27904@xxxxxxxxxxxxxxxxxxxxxxx> <20051001202856.GA134@DervishD> <1051002044052.ZM28373@xxxxxxxxxxxxxxxxxxxxxxx> <20051002190940.437F9866F@xxxxxxxxxxxxxxxxxxxxxxxx> <1051002195518.ZM2163@xxxxxxxxxxxxxxxxxxxxxxx>
Hi Bart :)
* Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> dixit:
> If we want to propagate errors that occur inside traps, and thereby
> make it possible for inline traps to "throw exceptions" in "always"
> blocks, we do this instead (more discussion below patch):
I insist: while ZERR may not be the place for throwing exceptions
(I think it's a perfect place, but that's another matter), signals
like SIGTERM, SIGINT, etc. or even SIGALRM, are very good candidates
to do exception handling. The best point about EH is that it allows
to do better error handling and cleanup, and traps are mostly used
exactly for that, so using the two things together is not as weird as
it may look.
Propagating "errflag" may break current code only if that code is
using an inline trap which "returns" a value and that error value is
ignored on purpose. Weird behaviour, to return a value you are going
to ignore as if it never existed. Moreover, simulating a "return"
from an inline trap is something difficult to do accidentally. It
would require messing with "$?" directly or something like that.
Of course, there are other code that may break: inline traps
which generate syntax errors (due to "eval" or the like, so the error
cannot be picked up always because it is produced only when the
"eval" parameters are ill formed or something like that) that
previously didn't cause any problem except maybe print an error
message and now will jump into the "always" block. But I don't think
there is much code out there using "always" blocks that can break.
I cannot think about any other code that may break due to the
last change you're proposing, but anyway your first patch seems
reasonable too: if inline traps cannot throw exceptions, do not let
function traps do it and document the problem (not about exceptions,
but about return values and syntax errors).
Raúl Núñez de Arenas Coronado
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to...
Messages sorted by: