Fork me on GitHub
#cljs-dev
<
2019-12-11
>
mkvlr14:12:44

we’re using this macro in Clojure to use namespaced keywords throughout our codebase while avoiding circular deps.

mkvlr14:12:51

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

mkvlr14:12:00

now we’re trying to add cljs support for this but there’s not alias there. Is there a workaround for this?

alexmiller14:12:02

you could just not use aliases?

dnolen14:12:21

@mkvlr somebody will need to add alias

mkvlr14:12:24

@alexmiller of course but that’s quite tedious to spell out or I don’t understand what you mean

dnolen14:12:05

one way to avoid this problem is specs only namespaces, at least IME

mkvlr14:12:53

@dnolen thanks, will consider that. But there’s also no particular reason why alias couldn’t be added?

alexmiller15:12:17

fyi, this is an area we might add a lightweight alias support (not requiring namespace creation/use) to Clojure (and ClojureScript) in future

👍 12
mkvlr15:12:45

I heard this, this would be 💯

dnolen15:12:39

there's nothing prevent alias but it's really annoying - not hard but you need to follow the rules for top-level require

4
dnolen15:12:47

well maybe hard - I don't know

dnolen15:12:03

the ns stuff is pretty gnarly - and this would be new thing - alias only - no namespace

dnolen15:12:39

but I don't see any problems with it no

dnolen15:12:22

create-ns isn't meaningful but could exist for compatibility

mkvlr15:12:18

alright, thanks for the pointers!