Why can't I: require: link in clojurescript?

See: https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure#namespaces

It bothers me that idiomatic clojure:

(ns clojure-example (:require [clojure.set :refer [union]])) 

But idiomatic clojurescript:

 (ns clojurescript-example (:use [clojure.set :only [union]])) 

Of course, clojurescript code will work in clojure too, but it reveals daemons that say I should use require instead of :refer !

What is the reason for this?

+6
source share
1 answer

In fact, ClojureScript supports :require :refer and has supported it for a long time ( here is my commit , offering support :refer from June 12, 2012). This wiki page is out of date. I updated the wiki namespace section to update it.

As for the idioms, there are, of course, people who do not like :use , but this hardly makes it uniomatic after several years of using the product. You yourself can think about whether you prefer :require :refer or not.

(Although the use case when :use does offer opportunities that :require does not fulfill - pulling multiple namespaces with (:use lib.foo lib.bar lib.quux) is not supported by default in ClojureScript).

+8
source

Source: https://habr.com/ru/post/958414/


All Articles