You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
typesetting/quad/quad2/pass.rkt

18 lines
601 B
Racket

#lang racket/base
(require racket/contract)
(provide (all-defined-out))
(define pass/c (any/c . -> . any/c))
(define-syntax-rule (define-pass (PASS-NAME ARG)
#:precondition PRECOND-PROC
#:postcondition POSTCOND-PROC
EXPRS ...)
(define/contract (PASS-NAME ARG)
pass/c
(unless (PRECOND-PROC ARG)
(error 'PASS-NAME (format "precondition failed: ~a" 'PRECOND-PROC)))
(define res (let () EXPRS ...))
(unless (POSTCOND-PROC res)
(error 'PASS-NAME (format "postcondition failed: ~a" 'POSTCOND-PROC)))
res))