[racket] Abstracting over redex language via macro causes scope issues

From: J. Ian Johnson (ianj at ccs.neu.edu)
Date: Tue Nov 29 19:44:21 EST 2011

Consider the following racket program:

#lang racket
(require redex/reduction-semantics)
(define-language L
  [bar natural]
  [H (side-condition (name f any) (foo (term f)))])
(define-syntax-rule (foo i) (redex-match L bar i))

This expands just fine. However, try to abstract over L via a macro:

#lang racket
(require redex/reduction-semantics)
(define-syntax-rule (M lang)
  (define-syntax-rule (foo i) (redex-match lang bar i)))
(define-language L
  [bar natural]
  [H (side-condition (name f any) (foo (term f)))])
(M L)

I get the error that foo is undefined. Why?

-Ian


Posted on the users mailing list.