Fork me on GitHub
#beginners
<
2015-07-06
>
surreal.analysis01:07:34

Running into (what I assume is) a basic issue with cljc files, and any help would be appreciated. I currently have a file called src/cljc/calculations.cljc, with a ns of:

(ns ef.calculations)
And a file called src/cljs/view.cljs which requires it. In my project.clj:
:cljsbuild {:builds {:app {:source-paths ["src/cljs"
                                            "src/cljc"]
                             :compiler {:output-to     "resources/public/js/app.js"
                                        :output-dir    "resources/public/js/out"
                                        :asset-path   "js/out"
                                        :optimizations :none
                                        :pretty-print  true}}}}
But, when I run lein cljsbuild once app I get the following error
Caused by: clojure.lang.ExceptionInfo: No such namespace: ef.calculations, could not locate ef/calculations.cljs, ef/calculations.cljc, or Closure namespace “ef.calculations" at line 1 src/cljs/ef/view.cljs {:file "src/cljs/ef/view.cljs", :line 1, :column 1, :tag :cljs/analysis-error}

Alex Miller (Clojure team)02:07:42

shouldn't the file be at src/cljc/ef/calculations.cljc ?

surreal.analysis02:07:56

I knew it’d be stupidly simple simple_smile Thanks @alexmiller

iae06:07:06

@dmich Yes, I also completed the example in F#

dmich13:07:11

@iae: So what was your experience using F# to solve this problem like?

samueldev17:07:01

I'm trying to wrap my head around two functions that I'm seeing a lot of in my cljs'ing

samueldev17:07:10

Reify and Defprotocol used in conjunction

samueldev17:07:39

Is there any analogy that could be drawn to some imperative OO-style concept with regards to these fn's and their use?

samueldev17:07:49

Is it sort of like defining an object and it's member methods?

seancorfield17:07:20

You can think of defprotocol sort of like an interface in Java, if that helps.

seancorfield17:07:48

Then reify creates an "object instance" on the fly (at runtime) that implements the interface.

seancorfield17:07:21

A bit like making an anonymous class object I guess…?

samueldev17:07:42

Cool I sort of figured as much

samueldev17:07:59

Thanks @seancorfield! You're in here an awful lot helping people out with silly questions like this, I greatly appreciate your generosity

seancorfield17:07:08

I’m in eight Slack teams (including one for work) — and I know what it’s like to be a beginner in a language (as I try to learn a new one every year) simple_smile

roberto18:07:17

is there a way to force alignment with paredit? For example:

(defn some-fn []
   (let [a (a-fn)
             bcd (b-fn) ]
        ;;;;;
))
To
(defn some-fn []
   (let [a        (a-fn)
             bcd  (b-fn) ]
        ;;;;;
))

roberto18:07:36

why oh why dear slack