Here's what I've come up with so far (wording rough; I'm in a rush
right now):
`&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 an ordered sequence of simple
conditions. A simple condition is equivalent to a compound condition
with only the simple condition as its component. A condition is
either a simple condition or a compound condition.
(condition cond1 ...)
Returns a condition object with the simple conditions of cond1 ... as
its components.
(simple-conditions cond)
Returns the components of cond.
(condition? thing)
Returns #t if thing is a (simple or compound) condition.
(condition-predicate rtd)
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>) ...)
<... essentially as before, except that the constructor is now
explicitly named. This creates a record type <type>, and is purely
for convenience.>
So you'd get, for example:
(define-condition-type &message &condition
make-message message-condition?
(message condition-message))
(condition-message (make-message "yo, dude, error"))
=> "yo, dude, error"
(condition-message
(condition (make-message "yo, dude, error")
(make-error)))
=> "yo, dude, error"
What do you think?
--
Cheers =8-} Mike
Friede, V?lkerverst?ndigung und ?berhaupt blabla
Received on Mon Apr 09 2007 - 13:46:22 UTC