[R6RS] "error" and "violation"

dyb at cs.indiana.edu dyb at cs.indiana.edu
Mon May 15 23:41:41 EDT 2006


> This got lost in the shuffle, so I'd like to propose it more
> formally.  Specifically, I suggest that these procedure be added, and
> that they behave as if they were defined as follows:
>
> (define (violation msg . irritants)
>   (raise
>    (condition
>     (&violation)
>     (&irritants (values irritants))
>     (&message (message msg)))))
>
> (define (error msg . irritants)
>   (raise
>    (condition
>     (&error)
>     (&irritants (values irritants))
>     (&message (message msg)))))
>
> where &irritants is a condition type with the following definition:
>
> (define-condition-type &irritants &condition
>   irritants?
>   (values condition-irritants))

I'd prefer that violation and error take a "who" argument, as in:

  (define (violation who msg . irritants)
    (raise
     (condition
      (&violation)
      (&who who)
      (&irritants (values irritants))
      (&message (message msg)))))
 
  (define (error who msg . irritants)
    (raise
     (condition
      (&error)
      (&who (values who))
      (&irritants (values irritants))
      (&message (message msg)))))

where &who is another condition type.  who should be a string or symbol
identifying the entity reporting the error (e.g., a procedure name) or
#f if the caller doesn't want to identify the entity.

I know that who could be incorporated into the message or added to the
irritants, but I've found that forcing people to identify where the
problem originates results in much clearer error reporting.

A compromise is to require the who argument to be a symbol or #f and make
it optional, i.e., if the first argument is a symbol, then it is the who
argument and the second must be the msg argument; otherwise, the first
argument must be the msg argument.

Incidentally, I still don't fully appreciate the distinction between
&error and &violation and, more importantly, when to use one and not the
other, and the draft exc.tex is vague on this point.

Kent



More information about the R6RS mailing list