Re: PreScheme exception handling
Michael Sperber <[email protected]> Sat, 21 Nov 2015 19:57:49 +0100
| Newsgroups | gmane.lisp.scheme.scheme48 |
|---|---|
| Message-ID | <[email protected]> |
Thomas Hintz <[email protected]> writes: > I'm attempting to use setjmp and longjmp with PreScheme to handle > exceptions. The problem is PreScheme pulls the result of the setjmp call > out of the if statement and instead stores its result in a variable > which the if statement then checks. For setjmp the call needs to be in > the if test itself or you get some wacky behavior (it would seem). > > So I need: > > if (!setjmp(buf)) { > handle_error > } else { > code_that_calls_longjmp(); > } > > but PreScheme generates: > > v = setjmp(buf)); > if ((0 == v)) { > code_that_calls_longjmp(); > } else { > handle_error > } > > Is there maybe some trick to get PreScheme to do what I want? Or is > there a better way to do it within PreScheme? I suspect what you're trying to do is fundamentally incompatible with a lot of the optimizations performed by the C compiler, which assume there can't be non-local transfer of control. I'd start by trying to declare the setjmp be a simple C primop. Or did you already do that? -- Regards, Mike