[plt-scheme] "transitivity" in module namespaces

From: Corey Sweeney (corey.sweeney at gmail.com)
Date: Wed Mar 30 12:25:07 EST 2005

I went to press one of my files into a module, and ran into a strange problem.

Here's i minimal mock up of the problem.


;;;;;;;;file bp.ss
(module bp (lib "plt-pretty-big-text.ss" "lang") 
(provide b->p)
(require (lib "plt-match.ss"))

 ;;use match in a function that's a first class citizen
(define (bnf->p list-in)
        [...]
(let ((match-expression
           (append
            `(lambda (x) match x)
              [... list-in ...]
              )))
      (eval match-expression)))))



;;;;;;;;next file xx.scm
(require "bp.ss")

;define what a var is
(define (var? x)   
    [...]
    )
  
(define P-BNF
  `(
     [...]
    (? var?)
     [...]
     ))

(define PC? (bnf->p P-BNF))

;[-- P-BNF is a list that contains the sublist (list ? var?), which
gets interpeted in the ;"(eval (match" and then includes var? in the
generated procedure --]

(PC? `(correct pc list))

this works fine, and the call to PC? returns true.  but if I:


;;;;;;;;next file xx.ss
(module xx
(require "bp.ss")
(provides PC?
              var?)

;define what a var? is
(define (var? x)   
    [...]
    )
  
(define P-BNF
  `(
     [...]
    (? var?)
     [...]
     ))

(define PC? (bnf->p P-BNF))


;;;;;;;;then next file yy.scm
(require  "xx.ss")
(PC? `(correct pc list))


then the call to PC? returns:

          ---reference to undefined identifier: var?---


so i thought it's geting eval'ed under the wrong namespace, so i make
var? available in every namespace (i cut and paste a copy of "define
var?" to bp.ss).  But even after this i still get the same error.

So you can see how I'm confused. It makes it through one module
interface, but not 2.  I thought maybe i needed to to explicitly set
the namespace for eval, but if that was the case, it shouldn't have
worked when xx.scm, which only required bp.ss, executed (PC? `(correct
pc list))



Corey



Posted on the users mailing list.