Previous: Scheme modules, Up: Scheme



13.6 Scheme exceptions and transactions

In VRR there may be an arbitrary depth of scheme/C switches on stack. GUILE Scheme uses exceptions for error signalization. Both exceptions and failed transactions contain some form of long jump. It is necessary to ensure that a failed transaction does not jump over some scheme sections on stack (and vice versa). It is accomplished by wrapping each C code executed from Scheme code by an anonymous transaction; and each Scheme code executed from the C code by the function scm_call_with_dynamic_root() which disallows any indirect returns from the Scheme code. A convenient way to call Scheme code from C is using the function call_guile_fn_from_c which does all the steps needed. Exceptions generated in Scheme code are translated to trans-fails in C code, and vice versa. But this conversion is not ideal, because VRR trans-fails contain just strings whereas GUILE exceptions contain arbitrary data; then an exception is early converted to a string for trans-fail and the next exception in a row is just a trans-fail exception.