Ignore the above post , I figured this out after reading little bit more , just need to properly structure the code , sorry for the noise :)
Thanks. On Wed, Jan 18, 2012 at 1:20 PM, Veer Singh <veer.c...@gmail.com> wrote: > Hello , > > How do I during compilation stop propagation of shared state in a some > module and allow propagation of shared state in other modules. > > Consider the following normal and compiled modules given below where > applying (add) produces list of symbols. > > Now in module m2 if there is some form like (require-special > "m1.rkt") then only (add) should produce '(m n a b x y) > Otherwise for normal require it should produce '(m n) which mean > (begin-for-syntax ...) in m1 is not touched or executed in different phase > when compiling m2. > > I can do other way around though i.e require-special expands to > (for-syntax "m1.rkt") which shifts the begin-for-syntax to phase 2 in m1 > and avoids the sharing. > But then I am unable to import "add" from m1 without using normal require. > > > > > (normal-module m1 racket > (require "defs.rkt") ; macro definitions for define-something and others > and manipulate shared state > > (provide add) > > (define-something (add x y) > ...) > > (define-something (add a b) > ...) > > (generate-defn) ; macro that generate (define (add) '(a b x y)) > > (add) ; should produce (list 'a 'b 'x 'y) > > ) > > > > (compiled-module m1 racket > (require "defs.rkt") > (provide add) > (begin-for-syntax > (add-to-hash! 'add '(x y)) > (add-to-hash! 'add '(a b))) > > > (define (add) '(a b x y)) ;result of (generate-defs) > (add) ; produces (list 'a 'b 'x 'y) > ... > ) > > > (normal-module m2 racket > (require "defs.rkt") > (require (prefix-in m1: "m1.rkt")) > > ;;(require (for-syntax "m1.rkt") ; > > (define-something (add m n) ...) > (generate-defs) > (add) > (m1:add) > ... > ) > > (compiled-module m2 racket > (require "defs.rkt") > (require "m1.rkt") > (begin-for-syntax > (add-to-hash! 'add '(m n))) > > (define (add) '(m n a b x y)) ;result of (generate-defs) > > (add) ;produces '(m n a b x y) > (m1:add) ;produces '(a b x y) > > ... > ) > > > > > > >
____________________ Racket Users list: http://lists.racket-lang.org/users