tags:

views:

92

answers:

1

When I try to run this code in eclipse:

(ns cl1 
  (def s 1)
  (print s)
)

I get

java.lang.Exception: No such var: clojure.core/def (clojure.clj:1)

I'm a complete clojure newbie, but I think that the above code should create the symbol s, and then print what s is equivalent to to the screen (1).

+5  A: 

def isn't used inside an ns declaration (ns is a macro, btw). try this instead:

(ns cl1)

(def s 1)
(println s)

http://clojure.org/namespaces

Joshua Smith
Aha! I thought you had to enclose the whole file with the namespace. This is the source of my confusion. Onward to learning!
JBristow