ClojureScript

require should try to automatically load a corresponding .clj file with require-macros semantics

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Declined
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

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.

Activity

Hide
David Nolen added a comment -

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

Show
David Nolen added a comment - the solution proposed for CLJS-721 avoids the problems inherent in implicitly loading the macro file.
David Nolen made changes -
Field Original Value New Value
Resolution Declined [ 2 ]
Status Open [ 1 ] Resolved [ 5 ]
David Nolen made changes -
Status Resolved [ 5 ] Closed [ 6 ]

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: