On 30-Mar-09, at 8:45 AM, Marc Feeley wrote:
- This could be "fixed" so that each level of the tower has its own
set of global variables, but I am worried about the cost of duplicating many variables (to be consistent all the Gambit predefined variables would have to be duplicated). Also I'm not sure this would be right semantically. Perhaps each module should have its own syntax environment, in other words it is not a single tower but a set of towers (*not* a tree). This is the purest model that ensures that something defined for syntax in one module is not available to the syntactic part of another module.
I've been looking into this some more. Let me just explain what I mean by "separate set of global variables".
I will use the notation Xi to denote instance i of module X. In a model with a syntactic tower, i is an integer "level" starting with i=0 for the run time level, and i=1 for its syntactic expansion level, etc.
Assume we have modules A and B like this:
;;; module A
(import B) (init-v 11)
(syntax-begin (import B) (init-v 22))
(define-macro (foo) (let ((z (* v 10))) `(cons ,z ,z)))
;;; module B
(define v #f)
(define (init-v x) (set! v x) (pp v))
Note that A requires B both for run time and expansion time. In a model with a syntactic tower there are two instances of B, that is B0 (run time) and B1 (expansion time). What is the relationship between v from B0 and v from B1 (let's call them B0.v and B1.v)? I feel that there should be no interaction between levels, except the macro expander acts as a bridge between levels. So B0.v and B1.v should be distinct variables.
Do we all agree on this?
There will be a substantial run time cost to implement this because each instance of a module is basically a closure, and thus there will be an additional indirection to access global variables.
Marc