<div dir="ltr">Matthias -<div><br></div><div>Hello... so, yes, Jay and I continued our discussion on the IRC channel.</div><div><br></div><div>To answer your question, yes, the code as written should behave as it does. </div><div><br></div><div>What I wanted was to make "a" not visible to the enclosing module unless it was exported via "provide" or an analogous operation. Jay's idea was to use "define" to create a module binding from "a" to a generated or decorated name, provide "a" (or not), and put the generated name in the hash table. I'm pursuing that approach currently.</div><div><br></div><div>Dan<br></div><div><br></div><div><br></div><div>PS: The motivation for this is to finally get our custom language "DC" to be implemented as a proper Racket module language.  It's turning out to be a bit of a nightmare since we rely so heavily on the side effects of "load" and we have 4 different namespaces active at once.  This example is just one small piece.</div><div><br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 3, 2014 at 5:31 AM, Matthias Felleisen <span dir="ltr"><<a href="mailto:matthias@ccs.neu.edu" target="_blank">matthias@ccs.neu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class=""><div>On Oct 27, 2014, at 7:00 PM, Dan Liebgold wrote:</div><br><blockquote type="cite"><div dir="ltr"><div>I have a namespace behind a particular API. I'd love to hook into the module system to control compilation, visibility, etc. of all the definitions and references.</div><div><br></div><div>Here's an example. 'a' is available in the top level module even though it was defined by module 'm1' and not provided by any explicit mechanism. (Also, order dependencies seem imminent.)</div></div></blockquote><div><br></div></span><div>Since you didn't reply to Jay's response, let me resume the thread. You had written not quite this: </div><span class=""><div><br></div><blockquote type="cite"><div dir="ltr"><div><span style="font-family:'courier new',monospace">#lang racket</span></div></div></blockquote><div><font color="#1755ca" face="'courier new', monospace"><br></font></div><div><font color="#1755ca" face="'courier new', monospace">(module base racket</font></div><div><font color="#1755ca" face="'courier new', monospace">  (define my-table (make-hasheq))</font></div><div><font color="#1755ca" face="'courier new', monospace">  </font></div><div><font color="#1755ca" face="'courier new', monospace">  (define-syntax (my-define stx)</font></div><div><font color="#1755ca" face="'courier new', monospace">    (syntax-case stx ()</font></div><div><font color="#1755ca" face="'courier new', monospace">      [(_ my-id expr) (identifier? #'my-id)</font></div><div><font color="#1755ca" face="'courier new', monospace">                      #'(hash-set! my-table 'my-id expr)]))</font></div><div><font color="#1755ca" face="'courier new', monospace">  </font></div><div><font color="#1755ca" face="'courier new', monospace">  (define-syntax (my-eval stx)</font></div><div><font color="#1755ca" face="'courier new', monospace">    (syntax-case stx ()</font></div><div><font color="#1755ca" face="'courier new', monospace">      [(_ my-id)</font></div></span><div><font color="#1755ca" face="'courier new', monospace">       #'(hash-ref my-table 'my-id #f)])) ;; <--- my first change </font></div><div><font color="#1755ca" face="'courier new', monospace">  </font></div><div><font color="#1755ca" face="'courier new', monospace">  (provide my-define my-eval))</font></div><span class=""><div><font color="#1755ca" face="'courier new', monospace"><br></font></div><div><font color="#1755ca" face="'courier new', monospace">(module m1 racket</font></div><div><font color="#1755ca" face="'courier new', monospace">  (require (submod ".." base))</font></div><div><font color="#1755ca" face="'courier new', monospace">  (my-define a (+ 1 2)))</font></div><div><font color="#1755ca" face="'courier new', monospace"><br></font></div><div><font color="#1755ca" face="'courier new', monospace">(require 'base 'm1)</font></div><div><font color="#1755ca" face="'courier new', monospace"><br></font></div></span><div><font color="#1755ca" face="'courier new', monospace">(my-eval a) ;; <--- my second change </font></div><div><font color="#1755ca" face="'courier new', monospace"><br></font></div><div><font color="#1755ca" face="'courier new', monospace"><br></font></div><div><font color="#1755ca" face="'courier new', monospace">;; --- </font></div><div><font color="#1755ca" face="'courier new', monospace"><br></font></div><div><font color="#1755ca" face="'courier new', monospace">When you write 'a' is available in the top-level module, even though you didn't import it, I don't see it. You imported all of base into the top level and m1. These imports include accessors to 'my-table' and 'm1' happened to store a key in this table. Why should you not be able to retrieve the value of 'a'? </font></div><span class="HOEnZb"><font color="#888888"><div><font color="#1755ca" face="'courier new', monospace"><br></font></div><div><font color="#1755ca" face="'courier new', monospace">-- Matthias</font></div><div><font color="#1755ca" face="'courier new', monospace"><br></font></div><div><font color="#1755ca" face="'courier new', monospace"><br></font></div><div><br></div></font></span></div><br></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Dan Liebgold    [<a href="mailto:dan.liebgold@gmail.com">dan.liebgold@gmail.com</a>]</div>
</div>