[racket] non-shared module variables

From: Tobias Hammer (tobias.hammer at dlr.de)
Date: Tue May 28 07:59:53 EDT 2013


i am trying to write a simple language that has variables that should not  
be shared, i.e that should be local to an invocation of the  

;; -------------------------------
#lang racket

;; lang
(module lang racket
   (provide (all-from-out racket)
            add get)

   (define state null)

   (define (add v)
     (set! state (cons v state)))

   (define (get)

;; mods
(module m (submod ".." lang)
   (add 'from-m)

(module n (submod ".." lang)
   (add 'from-n)

(require 'm)
(require 'n)
;; -------------------------------

This gives
'(from-n from-m)

but what i want is

That means the state-variables should be unique to n and m. The allowed  
functions inside the modules should at best be all from 'module context,  
but at least require and provide should be possible.

I tried overwriting #%module-begin and wrap the module body in  
parameterize, but this limits to expression-context. syntax-parameters  
with splicing-syntax-parameterize didn't work without converting  
everything in lang to macros which would add a lot of complexity.

So, the question is, what is the right way to get the desired behavior?


Tobias Hammer
DLR / Robotics and Mechatronics Center (RMC)
Muenchner Str. 20, D-82234 Wessling
Tel.: 08153/28-1487
Mail: tobias.hammer at dlr.de

Posted on the users mailing list.