On Apr 7, 2005, at 10:55 PM, ben@fuhok.net wrote:
What advantage does the more complicated error checking have over the simpler checking that I put in? Is there more to it than just consistency with the Gambit runtime?
Thank you for the diffs, I haven't looked at them yet, I've been working on answering this question.
Basically, your error-checker
(define (##check-arg pred val caller) (if (not (pred val)) (error "Bad argument type" val caller)))
can lead to trouble; if val is circular, for example, or a 10000-entry list, or ... then there will just be a whole lot of stuff dumped to the terminal until the user hits ^C. For example:
[zakon2-iro-umontreal-ca:~/programs/gambc40b12/ben] bjlucier% gsc Gambit Version 4.0 beta 12
(compile-file "char-set-lib.scm")
gcc: unrecognized option `-no-cpp-precomp' #t
(load "char-set-lib.scm")
"/Users/bjlucier/programs/gambc40b12/ben/char-set-lib.scm"
(load "char-set-lib")
"/Users/bjlucier/programs/gambc40b12/ben/char-set-lib.o1"
(define a (cons #f #f)) a
(#f . #f)
(set-cdr! a a) (char-set-adjoin char-set:lower-case a)
*** ERROR IN char-set-adjoin -- Bad argument type (#f #f #f #f #f #f #f #f #f #f #f #f #f #f #f #f #f #f <lines and lines of stuff removed>^C *** ERROR IN char-set-adjoin -- Deadlock detected
whereas if you use and extend slightly the built-in error-handling machinery that Marc built, you get
(load "../srfis/srfis")
"/Users/bjlucier/programs/gambc40b12/ben/../srfis/srfis.o2"
(char-set-adjoin char-set:lower-case a)
*** ERROR IN char-set-adjoin -- CHARACTER expected (char-set-adjoin '#<char-set #3 body: #u16(0 0 0 0 0 0 65534 2047 0 0 0 32 0 32768 65535 654... '(#f #f #f #f #f #f #f #f #f #f #f #f #f #f #f #f #f #f #f #f #f #f #f #f ...) 1>
Of course, all is not perfect:
(char-set-adjoin 1 #\c)
*** ERROR IN (console)@21.1 -- (Argument 1) Unknown type expected (char-set-adjoin 1 #\c) 1>
Marc, how do you fix this?
Anyway, I've included srfis 13 and 14 modified to work with gambc40b12 in this message. Put these files in a directory srfis in parallel with lib/gsi/gsc/... and compile with
(compile-file "srfis.scm" '(check))
if you want checking or
(compile-file "srfis.scm")
if you don't. (Another reason to do error checking the way I did, you can get rid of the checking easily.)
I also added
[zakon2-iro-umontreal-ca:~/programs/gambc40b12/ben] bjlucier% rcsdiff *.scm =================================================================== RCS file: RCS/char-set-lib.scm,v retrieving revision 1.1 diff -r1.1 char-set-lib.scm 5a6
(declare (standard-bindings)(extended-bindings)(block))
to your char-set-lib.scm.
Brad