Clojure is a Lisp, so it should be possible to extend it yourself ...
What about something like this?

(defmacro locally-using
  "Allows to use symbols from other namespace in the local scope
of the macro body.
Syntax: (locally-using [<symbol>*] :from <namespace>
          <body>)"
  [symbols from ns-name & body]
  (assert (= from :from) "Wrong syntax ... delimiter :from missing or
misplaced!")
  (let [local-vars (map (fn [sym] (symbol (str ns-name) (str sym)))
symbols)]
    `(do (require '~ns-name)
         (symbol-macrolet [~@(interleave symbols local-vars)]
                          ~@body))))

which then let's you write:
(locally-using [split] :from clojure.string (split "Hello world" #"
"))

The above macro could probably be made smarter to only require the lib
if it not already loaded and also "unload" when it is done in this
case. But since you have to load the lib anyways to use it and
qualified names do not clutter your current namespace, the above
version seems to be good enough.

Cheers,

    Nils

On Nov 23, 4:40 am, Igor TN <igor...@gmail.com> wrote:
> Yes, I meant local context. In principle, this could help to avoid
> namespacing conflicts in certain cases. But not a big deal, just
> wondering if the language supports that. Apparently not. Cool with me.
> Thanks everybody!
>
> On Nov 22, 6:59 pm, Alex Baranosky <alexander.barano...@gmail.com>
> wrote:
>
> > Looks like he'd like to make a namespace available *only* in a local
> > context, which some languages support, like Scala, for one.  I never have a
> > need for that, really.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to