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

Should a nil :ns-prefix be allowed in codegen/write-namespace!? #211

Open
harishcm opened this issue Aug 2, 2022 · 0 comments
Open

Should a nil :ns-prefix be allowed in codegen/write-namespace!? #211

harishcm opened this issue Aug 2, 2022 · 0 comments

Comments

@harishcm
Copy link
Contributor

harishcm commented Aug 2, 2022

Hi,

I was using codegen/write-namespace! and found that using a nil :ns-prefix results in a generated namespace that starts with a .. This makes the generated namespace an illegal Java class name.

I was wondering if a nil :ns-prefix would be an allowed? This would allow the same namespace patterns between Clojure and Python, making interop seem more "seamless".

A possible implementation would be the ns-symbol binding in codegen/write-namespace! ignoring a nil or blank :ns-prefix, e.g.,

(defn write-namespace! 
  ...
  (let [...
-       ns-symbol (or ns-symbol (symbol (str ns-prefix "." py-mod-or-cls)))]
+       ns-symbol (or ns-symbol (symbol (str (when-not (s/blank? ns-prefix) (str ns-prefix "."))
+                                            py-mod-or-cls)))]

I see that we can already define :ns-symbol directly to achieve a nil :ns-prefix, so this may already be allowed behaviour.

For your kind consideration.

Many thanks for this excellent library!

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

No branches or pull requests

1 participant