Hi,

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 module-language.

Example:
;; -------------------------------
#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)
    state))

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

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

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

This gives
'(from-m)
'(from-n from-m)

but what i want is
'(from-m)
'(from-n)

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



--
---------------------------------------------------------
Tobias Hammer
DLR / Robotics and Mechatronics Center (RMC)
Muenchner Str. 20, D-82234 Wessling
Tel.: 08153/28-1487
Mail: tobias.ham...@dlr.de
____________________
 Racket Users list:
 http://lists.racket-lang.org/users

Reply via email to