Fork me on GitHub
#cljs-dev
<
2016-08-01
>
anmonteiro12:08:35

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

anmonteiro12:08:40

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}}}

anmonteiro12:08:29

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

anmonteiro12:08:28

this is opposed to what happened previously, where all uses and use-macros were maps of symbol-> lib. e.g. {:uses {intersection clojure.set}}

anmonteiro12:08:06

basically my patch just adds one layer of indirection between the renamed symbol and the actual symbol in the lib that it refers to

anmonteiro19:08:20

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.

anmonteiro19:08:10

I’m also not sure if it’s even possible to implement ns :renames without breaking some tooling.