I think you want this:
#lang racket/base
(require (for-syntax racket/base
syntax/parse
racket/require-transform
racket/syntax))
(define-syntax ns-in
(make-require-transformer
(λ (stx)
(syntax-parse stx
[(_ mp:id)
(with-syntax ([mp: (format-id #'mp "~a:" #'mp)])
(expand-import
(syntax/loc stx
(prefix-in mp: mp))))]))))
(module+ test
(require (ns-in racket/list))
racket/list:empty)
On Wed, 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!")
>
> 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.
--
Jay McCarthy
Associate Professor
PLT @ CS @ UMass Lowell
http://jeapostrophe.github.io
"Wherefore, be not weary in well-doing,
for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great."
- D&C 64:33
--
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.