Riku Saikkonen <firstname.lastname@example.org> wrote:
| email@example.com () writes:
| >* Way to catch failure of primitive functions, such as e.g.
| > division by zero...
| It's not pretty, but this should work (in standard R5RS Scheme):
Nope, sorry! As has been noted several times before, R5RS specifically
does *NOT* promise this will work!!
6.4 Control features
(dynamic-wind before thunk after)
The effect of using a captured continuation to enter or exit the
dynamic extent of a call to "before" or "after" is undefined.
Plus, there is no guarantee anywhere in R5RS that "signalling an error"
interacts in any way with dynamic-wind!! At most an implementation is
required to "detect and report" certain errors, but it's not required to
do this by calling a continuation captured with call/cc in the top-level
REPL (albeit that's one "obvious" implementation), and thus it's not
required to execute any "after" thunks in any active dynamic-winds.
This means that R5RS call/cc + dynamic-wind are inadequate to implement
a portable exception-handling system. (...unless you add non-standard
extensions, as MzScheme & others have done.)
Rob Warnock, 31-2-510 firstname.lastname@example.org
SGI Network Engineering <URL:http://reality.sgi.com/rpw3/>
1600 Amphitheatre Pkwy. Phone: 650-933-1673
Mountain View, CA 94043 PP-ASEL-IA