[racket-dev] using module system for alternate namespaces
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/dev/archive/attachments/20141103/fbf9f349/attachment.html>