[racket-dev] using module system for alternate namespaces

From: Dan Liebgold (dan.liebgold at gmail.com)
Date: Mon Oct 27 19:00:08 EDT 2014

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.)

#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)]))

  (provide my-define
   my-eval)
  )

(module m1 racket
  (require (submod ".." base))
  (my-define a (+ 1 2))
  )

(require 'base
 'm1)

(my-eval 'a)


Is there any example of doing something like this using the module system
without polluting the top level namespace?  Am I correct in assuming that
this will not work under separate module compilation?

-- 
Dan Liebgold    [dan.liebgold at gmail.com]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/dev/archive/attachments/20141027/fe9cc127/attachment-0001.html>

Posted on the dev mailing list.