; Syntax-rules functions ; Copyright 2005 Brian Alliet ; Oleg's syntax-rules version of symbol? from comp.lang.scheme ; Copyright 2003 Oleg Kiselyov ; Message ID: 7eb8ac3e.0309301103.5200afbf@posting.google.com (define-syntax symbol?? (syntax-rules () ((symbol?? (x . y) kt kf) kf) ; It's a pair, not a symbol ((symbol?? #(x ...) kt kf) kf) ; It's a vector, not a symbol ((symbol?? maybe-symbol kt kf) (let-syntax ((test (syntax-rules () ((test maybe-symbol t f) t) ((test x t f) f)))) (test abracadabra kt kf))))) ; syntax-error is used to throw an error from a syntax-rule ; A call to syntax-error with args will not match any rules below and most Scheme implmentations ; will display the call and the arguments (which should contain some helpful error message) (define syntax-error (syntax-rules () ((syntax-error) (syntax-error "call me with args!"))))