This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-01
Channels
- # admin-announcements (8)
- # arachne (11)
- # beginners (17)
- # boot (64)
- # cider (26)
- # cljs-dev (7)
- # cljsrn (1)
- # clojure (115)
- # clojure-belgium (2)
- # clojure-dusseldorf (15)
- # clojure-poland (15)
- # clojure-russia (62)
- # clojure-spec (86)
- # clojure-uk (208)
- # clojurescript (36)
- # cursive (4)
- # datavis (11)
- # datomic (44)
- # editors (9)
- # hoplon (21)
- # jobs (4)
- # mount (21)
- # off-topic (3)
- # om (113)
- # onyx (65)
- # parinfer (2)
- # perun (3)
- # proton (6)
- # re-frame (29)
- # reagent (20)
- # yada (3)
I’ve added a patch to http://dev.clojure.org/jira/browse/CLJS-1508 (extend ns
form with the :rename
option).
I’d really appreciate some feedback on this one
The approach that I used was to add the renamed symbol to :use
and :use-macros
in the analyzer env. As an example:
(ns foo.core
(:require [clojure.set :as set :refer [intersection] :rename {intersection foo}]))
becomes:
{:uses {foo {intersection clojure.set}}}
when resolving uses and use-macros, we check if the “lib” is a map or a symbol. if it’s a map we use that (single) map entry instead
this is opposed to what happened previously, where all uses
and use-macros
were maps of symbol-> lib. e.g. {:uses {intersection clojure.set}}
basically my patch just adds one layer of indirection between the renamed symbol and the actual symbol in the lib that it refers to
FWIW, one disadvantage I see in the approach I took is tooling that might be expecting every val under the :uses
and :use-macros
maps to be a symbol. I suspect it might break some tooling downstream.
I’m also not sure if it’s even possible to implement ns :rename
s without breaking some tooling.