Ignore the above post , I figured this out after reading little bit more , just need to properly structure the code , sorry for the noise :) <div><br></div><div>Thanks.<br><div><br><div><br><br><div class="gmail_quote">On Wed, Jan 18, 2012 at 1:20 PM, Veer Singh <span dir="ltr"><<a href="mailto:veer.chah@gmail.com">veer.chah@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello ,<div><br></div><div>How do I during compilation stop propagation of shared state in a some module and allow propagation of shared state in other modules.</div>
<div><br></div><div>Consider the following normal and compiled modules given below where applying (add) produces list of symbols.</div>
<div><br></div><div><div>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)</div><div>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.</div>
<div><br></div><div>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.</div><div>But then I am unable to import "add" from m1 without using normal require.</div>
</div><div><br></div><div><br></div><div><br></div><div><br></div><div><div>(normal-module m1 racket</div><div> (require "defs.rkt") ; macro definitions for define-something and others and manipulate shared state</div>
<div><br></div><div> (provide add)</div><div><br></div><div> (define-something (add x y)</div><div> ...)</div><div> </div><div> (define-something (add a b)</div><div> ...)</div><div> </div><div> (generate-defn) ; macro that generate (define (add) '(a b x y))</div>
<div><br></div><div> (add) ; should produce (list 'a 'b 'x 'y)</div><div><br></div><div>)</div></div><div><br></div><div><br></div><div><br></div><div><div>(compiled-module m1 racket</div><div> (require "defs.rkt")</div>
<div> (provide add) </div><div> (begin-for-syntax</div><div> (add-to-hash! 'add '(x y))</div><div> (add-to-hash! 'add '(a b)))</div><div> </div><div> </div><div> (define (add) '(a b x y)) ;result of (generate-defs)</div>
<div> (add) ; produces (list 'a 'b 'x 'y)</div><div> ...</div></div><div>)</div><div><br></div><div><br></div><div><div>(normal-module m2 racket</div><div> (require "defs.rkt")</div><div> (require (prefix-in m1: "m1.rkt"))</div>
<div> </div><div> ;;(require (for-syntax "m1.rkt") ; </div><div> </div><div> (define-something (add m n) ...) </div><div> (generate-defs)</div><div> (add)</div><div> (m1:add)</div><div> ...</div></div><div>
)</div><div><br></div><div><div>(compiled-module m2 racket</div><div> (require "defs.rkt")</div><div> (require "m1.rkt")</div><div> (begin-for-syntax</div><div> (add-to-hash! 'add '(m n)))</div>
<div> </div><div> (define (add) '(m n a b x y)) ;result of (generate-defs)</div><div> </div><div> (add) ;produces '(m n a b x y)</div><div> (m1:add) ;produces '(a b x y)</div><div> </div><div> ...</div>
</div><div>)</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div>
</blockquote></div><br></div></div></div>