Matthias - Hello... so, yes, Jay and I continued our discussion on the IRC channel.
To answer your question, yes, the code as written should behave as it does. 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. Dan 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. On Mon, Nov 3, 2014 at 5:31 AM, Matthias Felleisen <matth...@ccs.neu.edu> wrote: > > On Oct 27, 2014, at 7:00 PM, Dan Liebgold wrote: > > 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. > > 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.) > > > Since you didn't reply to Jay's response, let me resume the thread. You > had written not quite this: > > #lang racket > > > (module base racket > (define my-table (make-hasheq)) > > (define-syntax (my-define stx) > (syntax-case stx () > [(_ my-id expr) (identifier? #'my-id) > #'(hash-set! my-table 'my-id expr)])) > > (define-syntax (my-eval stx) > (syntax-case stx () > [(_ my-id) > #'(hash-ref my-table 'my-id #f)])) ;; <--- my first change > > (provide my-define my-eval)) > > (module m1 racket > (require (submod ".." base)) > (my-define a (+ 1 2))) > > (require 'base 'm1) > > (my-eval a) ;; <--- my second change > > > ;; --- > > 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'? > > -- Matthias > > > > > -- Dan Liebgold [dan.liebg...@gmail.com]
_________________________ Racket Developers list: http://lists.racket-lang.org/dev