cljs-dev

ClojureScript compiler & std lib dev, https://clojurescript.org/community/dev
mkvlr 2019-12-11T14:36:44.480Z

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

mkvlr 2019-12-11T14:36:51.480400Z

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

mkvlr 2019-12-11T14:38:00.481600Z

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

alexmiller 2019-12-11T14:45:02.482Z

you could just not use aliases?

dnolen 2019-12-11T14:51:21.482300Z

@mkvlr somebody will need to add alias

mkvlr 2019-12-11T14:55:24.482900Z

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

dnolen 2019-12-11T14:57:05.483800Z

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

mkvlr 2019-12-11T14:58:53.484600Z

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

alexmiller 2019-12-11T15:00:17.486Z

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

👍 3
mkvlr 2019-12-11T15:00:45.486400Z

I heard this, this would be 💯

dnolen 2019-12-11T15:01:39.487Z

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

1
dnolen 2019-12-11T15:01:47.487300Z

well maybe hard - I don't know

dnolen 2019-12-11T15:02:03.487700Z

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

dnolen 2019-12-11T15:02:39.488100Z

but I don't see any problems with it no

dnolen 2019-12-11T15:03:22.488600Z

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

mkvlr 2019-12-11T15:06:18.489100Z

alright, thanks for the pointers!