PasteRack.org | ||
Paste # 89168 | ||
2019-10-12 10:51:50 | ||
Fork as a new paste. | ||
Paste viewed 130 times. | ||
Tweet | ||
Embed: | ||
#lang racket (require (for-syntax syntax/parse)) (begin-for-syntax (define-struct object (colour size)) (define ball (object 'red 'small)) (define-syntax-class struct [pattern s #:fail-unless (struct? (syntax-e #'s)) "Expected struct?"])) (define-syntax (touch-struct stx) (syntax-parse stx [(_ obj:struct) #`#,(object-colour #'obj)])) (define-syntax (run stx) (syntax-parse stx [(_) #'(touch-struct ball)])) (run) ;why does this fail?