notes.org 3.2 KB

Guile 3 and Guile 2.2.x

Guile 3 has introduced new ways of handling exceptions, which might be preferable to how it was done in Guile 2.2.x. This is the reason for there being separate examples.

To do [0/1]

  • [-] work in the feedback / improvement suggestions from the Guile users mailing list [1/2]
  • [ ] consider the impact of the "non-continuable exceptions" concept

Apparently "non-continuable exceptions" does not mean, that the program must exit or cannot continue, but rather, that the control flow cannot continue at the point, where the exception was raised. This has implications for the code in the example.

  1. ] In case of "non-continuable" exceptions the handler procedure given to
  2. ~with-exception-handler~ should not return. If it returns, then another "non-continuable" exception will be raised when it tries to return.

Q: I do not understand why it works this way yet. Why would another non-continuable exception be raised?

  1. ] For with-exception-handler from R6RS or R7RS the handler procedure is
  2. supposed to do one or more the following things:
  1. Do some exception handling actions.
  1. Call a call/ec "continuation object".
  • Guile 3's with-exception-handler does this automatically, if the
  • ~#:unwind?~ keyword argument is set to ~#t~.
  • This is the most similar to Guile 2.2's catch expression.
  • R6RS's or R7RS's guard expression is a wrapper around
  • ~with-exception-handler~ with ~#:unwind?~ set to ~#t~.
  • guard also allows for a cond expression, which enables to
  • specify different handlers for different exception.
  1. Re-raise the exception.
  1. Q: What is a call/ec continuation object? An object, which is a
  2. continuation, captured previously?
  • Q: What is the difference between a call/cc (current continuation) and a
  • ~call/ec~ (??? continuation) continuation object?
  • Calling a call/ec continuation object will unwind the stack.

Q: This means going back out the stack frames or throwing the stack frames away?

  • The stack will be unwound until a point is reached, where there is a
  • handler for the exception.
  • [X] Improvement suggestions
  • [X] For Guile 2.2 and 3:
  • [X] The first example should use #:unwind? #t, so that the program
  • does not end in a "non-continuable" exception.
  • [X] R6RS and R7RS exception procedures can only handle R6RS or R7RS
  • exceptions raised via ~raise~ or ~raise-continuable~, but not exceptions raised by Guile via ~throw~. The first example however will cause an exception raised by Guile via ~throw~. This means the first example should not work on Guile 2.2. --> Do not use this example in the Guile 2.2.x version of the examples.
  • [X] For Guile 3:
  • [X] Use Guile's exception objects instead of R6RS or R7RS conditions, by
  • using ~make-exception~ instead of ~condition~, which are more or less the same, but it expresses things in terms of Guile 3 vocabulary.
  • Q: But why is this better? Would not be condition more portable to
  • other Schemes?