we’re using this macro in Clojure to use namespaced keywords throughout our codebase while avoiding circular deps.
(defmacro ns-alias
"Set up a custom alias for use with namespace keywords.
(ns-alias com.nextjournal.journal.system sys)"
[ns as]
`(do
(create-ns '~ns)
(alias '~as '~ns)))
now we’re trying to add cljs support for this but there’s not alias
there. Is there a workaround for this?
you could just not use aliases?
@mkvlr somebody will need to add alias
@alexmiller of course but that’s quite tedious to spell out or I don’t understand what you mean
one way to avoid this problem is specs only namespaces, at least IME
@dnolen thanks, will consider that. But there’s also no particular reason why alias
couldn’t be added?
fyi, this is an area we might add a lightweight alias support (not requiring namespace creation/use) to Clojure (and ClojureScript) in future
I heard this, this would be 💯
there's nothing prevent alias
but it's really annoying - not hard but you need to follow the rules for top-level require
well maybe hard - I don't know
the ns stuff is pretty gnarly - and this would be new thing - alias only - no namespace
but I don't see any problems with it no
create-ns
isn't meaningful but could exist for compatibility
alright, thanks for the pointers!