Should a `nil` `:ns-prefix` be allowed in `codegen/write-namespace!`?
harishmohanadas opened this issue · comments
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!