;;;; condition-utils.inline.scm -*- Scheme -*- ;;;; Kon Lovett, Jan '25 (define-type condition-predicate (* -> boolean : condition)) (define-type condition-property-accessor (condition -> *)) (define-syntax on1st (syntax-rules () ((on1st ?typ ?e0 ...) (let ((+pred+ (the (or false ?typ) #f))) (lambda (x) (unless +pred+ (set! +pred+ (begin ?e0 ...))) (+pred+ x)) ) ) ) ) (define-syntax define-condition-predicate (syntax-rules () ((define-condition-predicate ?n ?d0 ...) (define ?n (on1st condition-predicate (make-condition-predicate ?d0 ...))) ) ) ) (define-syntax define-condition-property-accessor (syntax-rules () ((define-condition-property-accessor ?n ?d0 ...) (define ?n (on1st condition-property-accessor (make-condition-property-accessor ?d0 ...))) ) ) )