Behaviour of setjmp/longjmp and registers

Jim Shankland jas at ernie.Berkeley.EDU
Mon Jan 23 13:41:20 AEST 1989


In article <9480 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) writes:
>Really, setjmp/longjmp is just a groady "goto" and should be
>avoided for the same reasons as the ordinary "goto".  In fact
>it is even more violent than an ordinary "goto", which is why
>it has to be more loosely constrained.  I don't think I've
>even seen a case in which setjmp/longjmp was the best way to
>design code, let alone essential.

You can build a pretty nice exception mechanism on top of setjmp/longjmp.
Having some functions (memory allocation is a good example) raise
exceptions rather than returning an error status can unclutter your
code and give your weary typing fingers a rest.  (Not as much as not
checking error statuses at all, but we all know better than that --
don't we?)

Jim Shankland
jas at ernie.berkeley.edu

"I've been walking in a river all my life, and now my feet are wet"



More information about the Comp.lang.c mailing list