[R6RS] [r6rs-discuss] [Formal] Why are simple conditions so different from records
sperber at informatik.uni-tuebingen.de
Thu May 10 12:45:57 EDT 2007
Revised wording follows. Comments welcome. (I also have a reference
implementation, so I have some indication that this works in practice.
Let me know if you want it.)
`&condition' is a regular record type at the top of a record-type
hierarchy for simple conditions. New condition types are subtypes of
this record type. Condition objects are either simple conditions, or
compound conditions consisting of a list of simple conditions, its
*components*. As far as the condition system itself is concerned, a
simple condition is identified with a compound condition with the simple
condition as its only component. (However, simple conditions can be
distinguished from compound conditions by means of a predicate obtained
from `&condition'.) Compound conditions, i.e. conditions that are not
simple conditions, are members of a distinct type. (Possibly, but not
required to be a record.)
(condition cond1 ...)
Returns a (simple or compound) condition object with the simple
conditions of cond1 ... as its components.
Returns a list of the components of cond.
Note: Because `condition' decomposes its arguments into simple
conditions, the components of a condition is always a "flattened" list
of simple conditions.
Returns #t if thing is a (simple or compound) condition.
Returns a procedure that accepts a single argument. That procedure
returns #t if its argument is a condition of the condition type
represented by rtd, i.e. if it's either a simple condition of that
record type (or one of its subtypes) or a compound conditition with
such a simple condition as a component.
(condition-accessor rtd simple-accessor)
Rtd must be an rtd of a subtype of &condition. Simple-accessor should
be an accessor for that rtd. Returns a procedure that accepts a
single argument, which must be a condition of the condition type
represented by rtd. This procedure extracts the first component of
the condition of the condition type represented by rtd, and returns
the result of applying simple-accessor to that component.
(define-condition-type <type> <supertype> <constructor> <predicate>
(<field> <accessor>) ...)
... is as before, except that the constructor is now explicitly named.
This creates a record type <type>, and is purely for convenience.
(define-condition-type &message &condition
(condition-message (make-message "yo, dude, error"))
=> "yo, dude, error"
(condition (make-message "yo, dude, error")
=> "yo, dude, error"
Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla
More information about the R6RS