[gambit-list] Suggested change to how errors are displayed

Bradley Lucier lucier at math.purdue.edu
Sat Nov 5 21:56:13 EST 2005


Marc:

In my array code I do lots of things like:

(define (Interval-dimension interval)
   (or (and (not (Interval? interval))
	   (error "Interval-dimension: argument is not an interval: "  
interval))
       (##Interval-dimension interval)))

If I make a mistake and pass a large object that is not an Interval  
(like an array with a few million elements in it) to Interval- 
dimension, the code in _repl.scm writes out the whole argument to  
error and I have to try to hit ^C really, really fast before the  
location of the error scrolls off the screen.

I think it would be better to change the code for (##display- 
exception exc port) in _repl.scm to something like

           ((macro-error-exception? exc)
            (##display (macro-error-exception-message exc) port)
            (##for-each
             (lambda (arg)
               (##newline port)
               (##write arg port ##error-arg-write-width))
             (macro-error-exception-parameters exc))
            (##newline port))

and define

(define ##error-arg-write-width 72)

(set! ##error-arg-write-width ##error-arg-write-width)

outside that function.  Now I get nice error messages like

 > (set! ##error-arg-write-width 120)
 > (load "convex2.scm")
*** ERROR IN build-Array, "../generic-arrays.scm"@472.5 -- build- 
Array: accessor is not a procedure:
#<Array-base #4 domain: #<Interval #5 lower-bounds: #(0 0) upper- 
bounds: #(256 256)> accessor: #<procedure #6> setter: #

and I can work with this ;-).

Brad



More information about the Gambit-list mailing list