On Dec 20, 2012, at 8:55 PM, Seth Chandler <
chandl...@gmail.com> wrote:
> but in dealing with file locations, dependency management, projects, Leiningen, all of which are -- with due respect -- very difficult, particularly for people not coming from an Eclipse or similar background.
In my book, I decided to have everyone work at the repl, using only cutting-and-pasting or `load-file`. It's a 325-page book that never talks about namespaces or the `ns` macro.
The beginning instructions about how to do the exercises looks like this:
> You can copy and paste Clojure text into
> the repl. It handles multiple lines just fine.
>
> [… a note about possible glitches when copying from a PDF]
>
> If you want to
> use a Clojure command to load a file like (for example) `solutions/add-and-make.clj`,
> use this:
>
> {:lang="clojure"}
> ~~~~~~~~~~
> user> (load-file "solutions/add-and-make.clj")
> ~~~~~~~~~~
>
> *Warning*: I'm used to using `load` in other languages, so I
> often reflexively use it instead of `load-file`. That leads
> to this
> puzzling message:
>
> {:lang="clojure"}
> ~~~~~~~~~~
> user=> (load "sources/without-class-class.clj")
> FileNotFoundException Could not locate sources/without-class-class.
> clj__init.class or sources/without-class-class.clj.clj on classpath:
> clojure.lang.RT.load (RT.java:432)
> ~~~~~~~~~~
>
> The clue to my mistake is the ".clj.clj" on the next-to-last line.
These instructions seem to work well for my readers.
--------
Occasional consulting on programming technique
Contract programming in Ruby and Clojure
Latest book: /Functional Programming for the Object-Oriented Programmer/
https://leanpub.com/fp-oo