- (case-coerce CASE ...) => PROCEDUREsyntax
Returns a coercion procedure for use with extend-coerce.
CASE is of the form ((TYPE-TAG ...) EXPRESSION ...), or (else EXPRESSION ...).
The variable object is bound to the object to coerce within the scope of CASE ....
The variable on-error is bound to a thunk within the scope of CASE ...} to invoke upon failure.
(define (unspecified? obj) (eq? (void) obj)) (define unspecified-coerce (case-coerce ((char) #\nul) ((number) +nan) ((string) "") ((symbol) '||) ((list) (list)) ((vector) (vector)))) (coerce-extend! 'unspecified unspecified? unspecified-coerce) (type-of (void)) ;=> unspecified (coerce-extend! 'string string? (case-coerce ((unspecified) (if (string=? "" object) (void) (on-error))))) (coerce "" 'unspecified) ;=> (void)