Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing qualified macros re-imports hy.core.macros as qualified as well #1978

Closed
peaceamongworlds opened this issue Feb 20, 2021 · 3 comments · Fixed by #1979
Closed

Importing qualified macros re-imports hy.core.macros as qualified as well #1978

peaceamongworlds opened this issue Feb 20, 2021 · 3 comments · Fixed by #1979

Comments

@peaceamongworlds
Copy link
Contributor

Qualified macro imports don't seem to work as expected.

$ > hy --repl-output-fn=hy.contrib.pprint.pformat
hy 0.20.0 using CPython(default) 3.9.1 on Linux
=> (require [hy.contrib.walk :as w])
=> (w.let [a 1] (+ a 1))
2 ; as expected
=> (w.cond [True :true])
:true ; unexpected - why is `w.cond` defined?
=> (lfor [k v] (.items --macros--) (unmangle k))
["koan" "ideas" "defmacro" "if" "deftag" "macro-error" "defn" "defn/a" "as->" "assoc" "with"
 "with/a" "cond" "->" "doto" "->>" "of" "if-not" "lif" "lif-not" "when" "unless" "with-gensyms"
 "defmacro/g!" "defmacro!" "defmain" "comment" "doc"
 "w.defmacro"  "w.hyx-if" "w.deftag" "w.macro-error" "w.defn"                          ; where
 "w.hyx-defnXsolidusXa" "w.hyx-as-XgreaterHthan-signX"                                 ; do
 "w.assoc" "w.hyx-with" "w.hyx-withXsolidusXa" "w.cond"                                ; all
 "w.-hyx-XgreaterHthan-signX" "w.doto" "w.-hyx-XgreaterHthan-ignXXgreaterHthan-signX"  ; of
 "w.of" "w.if-not" "w.lif" "w.lif-not" "w.when" "w.unless" "w.with-gensyms"            ; these
 "w.hyx-efmacroXsolidusXgXexclamation-markX" "w.hyx-defmacroXexclamation-markX"        ; come
 "w.defmain" "w.comment" "w.doc" "w.smacrolet" "w.let"]                                ; from?

Surely only macros from the specified module should be imported as qualified, and not anything else?

@Kodiologist
Copy link
Member

That's the same way Python imports work. Why would you expect otherwise?

@Kodiologist Kodiologist removed the bug label Feb 20, 2021
@peaceamongworlds
Copy link
Contributor Author

I guess I didn't realise that Hy implicitly imports everything from hy.core in every module. Then this would make sense.

@Kodiologist
Copy link
Member

Yeah, that's the sort of namespace pollution that we'd like to avoid in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants