[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gcl-devel] condition system proposal
From: |
Peter Wood |
Subject: |
Re: [Gcl-devel] condition system proposal |
Date: |
Tue, 5 Nov 2002 09:01:40 +0100 |
User-agent: |
Mutt/1.4i |
Hi
On Fri, Nov 01, 2002 at 12:03:20AM -0500, Camm Maguire wrote:
>
> d) Until we standardize on the ansi image (at least), whatever
> we do has to work with the traditional image as well. clcs
> overwrites the function 'error' defined in error.c for the
> traditional image.
>
Aside from the show-stopper of derailing Maxima/ACL2, I am happy to
report that my ansi (disclaimer: preliminary, experimental) condition
types 'just work' with the traditional image. It is not necessary to
define-error-condition(s) for the new type(s), since serror does it
automatically. Note the last example. Cute, huh?
>(list-all-packages)
(#<"TK" package> #<"DEFPACKAGE" package> #<"ANSI-LOOP" package>
#<"SERROR" package> #<"SLOOP" package> #<"COMPILER" package>
#<"SYSTEM" package> #<"KEYWORD" package> #<"COMMON-LISP" package>
#<"USER" package> #<"LISP" package>)
>(defmacro ignore-errors (&rest forms)
`(serror:cond-any-error (error) (progn ,@forms) (t (values nil error))))
IGNORE-ERRORS
>(ignore-errors foo)
NIL
#S(SERROR::ERROR-CONDITION SERROR::NAME UNBOUND-VARIABLE STRING
"The variable ~S is unbound." FUNCTION PROGN
SERROR::CONTINUE-STRING "" SERROR::FORMAT-ARGS (FOO)
SERROR::ERROR-HANDLER-ARGS
(UNBOUND-VARIABLE NIL PROGN "" "The variable ~S is unbound." FOO))
>(ignore-errors (foo))
NIL
#S(SERROR::ERROR-CONDITION SERROR::NAME UNDEFINED-FUNCTION STRING
"The function ~S is undefined." FUNCTION PROGN
SERROR::CONTINUE-STRING "" SERROR::FORMAT-ARGS (FOO)
SERROR::ERROR-HANDLER-ARGS
(UNDEFINED-FUNCTION NIL PROGN "" "The function ~S is undefined."
FOO))
>(ignore-errors (package-name "not a package"))
NIL
#S(SERROR::ERROR-CONDITION SERROR::NAME :SIMPLE-PACKAGE-ERROR STRING
"There is no package with the name ~A." FUNCTION PACKAGE-NAME
SERROR::CONTINUE-STRING "" SERROR::FORMAT-ARGS ("not a package")
SERROR::ERROR-HANDLER-ARGS
(:SIMPLE-PACKAGE-ERROR NIL PACKAGE-NAME ""
"There is no package with the name ~A." "not a package"))
>(defun rec-inf (a) (if (> a 0) (rec-inf (1+ a)) a))
REC-INF
>(ignore-errors (rec-inf 1))
NIL
#S(SERROR::ERROR-CONDITION SERROR::NAME :SIMPLE-STORAGE-CONDITION
STRING "Frame stack overflow." FUNCTION REC-INF
SERROR::CONTINUE-STRING "" SERROR::FORMAT-ARGS NIL
SERROR::ERROR-HANDLER-ARGS
(:SIMPLE-STORAGE-CONDITION NIL REC-INF ""
"Frame stack overflow."))
>
You've gotta respect how essentially robust GCL is. Neither CLISP's
nor Lispworks' (trial edition) 'ignore-errors will handle the last
example. CMUCL (presumably) continues 'forever'. Only SBCL comes
close to doing 'the right thing', but incorrectly calls the error
condition a simple-error when this
'SB-KERNEL:%DETECT-STACK-EXHAUSTION' surely should signal a
storage-condition (IMHO ;-))
Regards,
Peter