> On Jun 29, 2016, at 9:05 AM, Shakna Israel <[email protected]> wrote:
> 
> I'm trying to introduce an implicit binding for require.
> 
> One of the features I love about Python, is the namespace binding.
> 
> import sys
> 
> sys.stdout.write("Sweet")
> 
> I know this can also be accomplished with require by specifying a prefix-in, 
> or a prefix-out with a local-require.
> 
> However, I want a require that does that for me.
> 
> (require racket/base)
> (racket/base:println "It works!")

Would something like

(require syntax/parse/define (for-syntax racket/base racket/syntax))
(begin-for-syntax
  (define-syntax-class path
    [pattern path:id #:with prefix (format-id #'path "~a:" #'path)]))
(define-simple-macro (new-require path:path ...)
  (require (prefix-in path.prefix path.path) ...))

Work for you?

> Figuring the namespace mangling is simple enough.
> 
> However, for this to work, I think I need a require transformer, but I'm at a 
> loss. The only example I see can mess with the module path, but not the 
> symbols it exposes.
> 
> Any pointers?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to