Next: syntaxes try, Up: syntaxes [Contents][Index]
The standardised Scheme languages do not define the common return
keyword present in many
languages, like C and Python. Despite this, it is quite easy to obtain the “early return”
functionality through the use of continuations:
(call/cc (lambda (return) (display 'before) (return 1) (display 'never))) -| before ⇒ 1
Many programmers are used to the return
keyword, so MMCK Exceptional Conditions includes some syntaxes
to support it. The use of all these syntaxes involves the creation of a continuation, which is a
performance penalty.
This syntax is meant to be used to return from some enclosing block, returning the given optional arguments. Being a fluid syntax: it is possible to rebind this keyword in custom syntaxes.
Like begin
, but allow the use of the keyword return
to return values to the enclosing
continuation.
Usage examples:
(returnable (display 'before) (return) (display 'never)) -| before (returnable (display 'before) (return 1) (display 'never)) -| before ⇒ 1 (returnable (display 'before) (return 1 2) (display 'never)) -| before ⇒ 1 2
Next: syntaxes try, Up: syntaxes [Contents][Index]
This document describes version 0.1.0-devel.1 of MMCK Exceptional Conditions.