.cljc, .clj require precedence

94 views
Skip to first unread message

Alan Dipert

unread,
Jul 18, 2015, 10:29:36 AM7/18/15
to cloju...@googlegroups.com
Hello,
I noticed this week that in the presence of two files on the classpath, one named foo/bar.clj, and another named foo/bar.cljc, (require 'foo.bar) on 1.7.0 loads the .clj file, not the .cljc file.

I was surprised by this behavior because I see the .cljc file as more "specific".  It seems like 1.7 preferring .cljc could simplify things slightly for library authors targeting both 1.6 and 1.7 consuming applications.  Authors could generate .clj and .cljs from .cljc at build-time and distribute them alongside the .cljc sources.

Does it make sense to change and/or specify the extension preference?  Is this already specified somewhere that I've missed?  Thank you in advance for sharing your thoughts.

Alan

Alex Miller

unread,
Jul 18, 2015, 11:28:06 AM7/18/15
to cloju...@googlegroups.com, al...@dipert.org
Hey Alan,

This is mentioned on the reader conditionals page. Platform-specific files take precedence so that you could ship a totally specific version of one or more platforms, then fall back to a cljc default with generic cross-platform behavior.

Alex
Reply all
Reply to author
Forward
0 new messages