[plt-scheme] modules and custom match expanders

From: Dimitris Vyzovitis (vyzo at media.mit.edu)
Date: Fri May 4 23:10:17 EDT 2007

I am running into a problem with custom match expanders and modules.
The following fails to expand in a module:

(module test mzscheme
  (require (lib "plt-match.ss"))

  (define-match-expander exp1
    #:plt-match
    (lambda (stx)
      (syntax-case stx ()
        ((_match (x y))
         #'(list (list x y))))))

  (define-match-expander exp2
    #:plt-match
    (lambda (stx)
      (syntax-case stx ()
        ((_match x y)
         #'(exp1 (x y))))))

  (define (test tp)
    (match tp ((exp2 x y) x)))

)

stdin::812: compile: unbound variable in module in: x

The same code *outside* a module expands fine.

-- vyzo
-------------- next part --------------
(module match-scase mzscheme
  (require (lib "plt-match.ss"))
  
  (define-match-expander exp1
    #:plt-match
    (lambda (stx)
      (syntax-case stx ()
        ((_match (x y))
         #'(list (list x y))))))
  
  (define-match-expander exp2
    #:plt-match
    (lambda (stx)
      (syntax-case stx ()
        ((_match x y)
         #'(exp1 (x y))))))
  
  (define (test tp)
    (match tp ((exp2 x y) x)))

)

Posted on the users mailing list.