Ken Wesson <kwess...@gmail.com> writes:

Hi Ken,

>> Why do I use a dynamic var in the first place?  I want to use the
>> simple names in the lexical scope of the `with-schema-imports' block,
>> and I used a dynamic var only because the resolution takes place
>> somewhere in the function call tree originating from there.  So a
>> much cleaner solution is to walk the body given to my macro and
>> replace the simple names with qualified names, so that at runtime
>> everything is fully qualified.
>
> This gets tricky if there are local names that are the same that
> should shadow it, though.

You mean, in the case of both Locality and localities.Locality being
valid names?  If you "import" the latter in that case, Locality refers
to the one in the localities package, and to access the Locality in the
default package, one would need to qualify it: ".Locality".

> If it's the lexical scope and you're just passing symbols to called
> functions, i.e. if you did none of this that lexical scope would be
> loaded with things like
>
> (some-fn this that 'localities.Locality the-other)
>
> then why not just wrap in
>
> (let [Locality 'localities.Locality]
>   ...)
>
> and maybe make a sugaring macro that expands
>
> (the-macro [localities.Locality foo.Bar baz.Quux ...]
>   ...)
>
> into
>
> (let [Locality 'localities.Locality
>       Bar 'foo.Bar
>       Quux 'baz.Quux
>       ...]
>   ...)

>From a user-perspective, that has the downside of having to quote in the
normal case and to drop the quoting in the import case.  But of course,
it has the advantage of being free to define custom, short aliases.

Thanks & bye,
Tassilo

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