> On Oct 3, 2017, at 10:31 AM, 'Shakin Billy' via Racket Users > <firstname.lastname@example.org> wrote: > > how do i access the pattern variable var at compile time (phase 1?) > additional to an answer, could you point me to the right part of the > documentation? i really couldn't find it.
`var` isn't a `procedure?` during phase 1. It's just a piece of syntax. So your `cond`, which is evaluated in phase 1, will always fail. But if you shift the `cond` to phase 0, by putting it inside the syntax template, it will work: #lang racket (require rackunit) (define inp (open-input-string "12+34")) (define-syntax (terminal stx) (syntax-case stx () ((_ name rx) (if (pregexp? (syntax->datum #'rx)) #'(define (name) (regexp-try-match rx inp)) #'(error "Pregexp expected."))))) (define-syntax (prod stx) (syntax-case stx () ((_ prod-name (name var)) #'(cond ((procedure? var) 0) (else (error 'PROD-ARGUMENTS "Pregexp oder Procedure expected.")))))) (terminal digit #px"\\d") (check-equal? (prod term (op1 digit)) 0) (define not-a-procedure 42) (check-exn exn:fail? (λ () (prod term (op1 not-a-procedure)))) -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.