clojure - lib names inside prefix lists must not contain periods -
i learning clojure now, wrote file this:
;; file ./mycode/myvoc.clj (ns mycode.myvoc (:use 'clojure.java.io) (:import (java.io.file))) ; more code here...
this file resides in ./mycode/
, when run repl, wanna use function in myvoc.clj
, this:
user=> (use 'mycode.myvoc) java.lang.exception: lib names inside prefix lists must not contain periods (myv oc.clj:1)
i don't know why. if change myvoc.clj
:
(ns mycode.myvoc) ; (:use 'clojure.java.io) ; (:import (java.io.file)))
it'll ok report no "reader in context" commented import part.
could fix this? alse use require
same kind of error.
you need remove quote :use
clause:
(ns mycode.myvoc (:use clojure.java.io) ; note no ' (:import java.io.file)) ; parens removed here; no harm, ; though
'clojure.java.io
shorthand (quote clojure.java.io)
, original :use
clause was
(:use (quote clojure.java.io))
this looks if trying :use
namespace prefix of quote
, final segment clojure.java.io
. dots in latter direct cause of error point of view of ns
.
incidentally, it's more usual (:require [clojure.java.io :as io])
, io/file
, io/reader
etc. pull in entire namespace.
finally, clear, quote necessary when using function use
(like in (use 'mycode.myvoc)
call), opposed :use
clause in ns
declaration.
Comments
Post a Comment