handler-case
is key to handling conditions in Common Lisp, but GCL 2.6.12 on Ubuntu 18.04 considers it to be an undefined function:
>(handler-case (error "test") (error (condition) condition))
Error: UNDEFINED-FUNCTION :NAME HANDLER-CASE
Fast links are on: do (si::use-fast-links nil) for debugging
Signalled by EVAL.
UNDEFINED-FUNCTION :NAME HANDLER-CASE
Broken at EVAL. Type :H for Help.
1 Return to top level.
>>
The same is true for handler-bind
.
The only function related to handling conditions or errors that is obvious in the GCL manual is the GCL-specific universal-error-handler
.
How can conditions be handled in GCL, preferably in a way that is supported by other Lisps?
The situation is explained in the project's README.Debian
:
[...] The common lisp standard in effect when GCL was first released is known as "Common Lisp, the Language" (CLtL1) after a book by Steele of the same name providing this specification. Subsequently, a much expanded standard was adopted by the American National Standards Institute (ANSI), which is still considered the definitive common lisp language specification to this day.
[...]
To toggle the use of the ANSI image, set the environment variable GCL_ANSI to any non-empty string.
(This Debian bug has a little more info.)
handler-case
requires ANSI support, so on Debian-based systems, GCL needs to be started with the GCL_ANSI
environment variable set; for example:
$ GCL_ANSI=1 gcl
To reflect the change, the first line of the startup message changes from:
GCL (GNU Common Lisp) 2.6.12 CLtL1 Fri Apr 22 15:51:11 UTC 2016
To:
GCL (GNU Common Lisp) 2.6.12 ANSI Fri Apr 22 15:51:11 UTC 2016
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With