<< Back to previous view

[CLJS-563] require should try to automatically load a corresponding .clj file with require-macros semantics Created: 29/Jul/13  Updated: 10/Dec/13  Resolved: 10/Dec/13

Status: Closed
Project: ClojureScript
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Jozef Wagner Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None


A common pattern in CLJS projects is to have macros in the .clj file with the same name as the .cljs file. The loading of such namespace is than usually done as follows (see also this comment) :

(:require [foo :as f]) (:require-macros [foo :as f])

Require is for loading libs, not files, as stated in http://clojure.org/libs . I propose to define a lib in CLJS as a pair of files, one with .cljs and one with .clj, with either file being optional. That way the special macro loading in CLJS will be transparent to the user.

With this change, require should thus try to always load also a corresponding .clj file and treat it as it would with require-macros. Only one file type (.clj or .cljs) should be required for require clause to be successfull.

require-macros functionality should be left unchanged, to allow a backward compatibility.

Don't know about the implementation details of this enhancement, but probably only analyzer.clj will have to be changed. An open question is the functionality and implementation of the :refer in such modified :require.

Comment by David Nolen [ 10/Dec/13 9:18 AM ]

the solution proposed for CLJS-721 avoids the problems inherent in implicitly loading the macro file.

Generated at Sat Jan 20 13:22:50 CST 2018 using JIRA 4.4#649-r158309.