0

When running this code :


    (:use 'compojure.core)
    (keys (ns-publics 'compojure.core))


    (defroutes app-routes
      (GET "/" [] "Hello World")
      (route/resources "/")
      (route/not-found "Not Found"))

I got this message:

CompilerException java.lang.RuntimeException: Unable to resolve symbol: defroutes in this context, compiling:(restful_clojure\routes.clj:5:1) 

but when I run:


    (keys (ns-publics 'compojure.core))

it shows that macro is defined:


    (defroutes PUT POST routing routes make-route let-routes DELETE ANY let-request GET HEAD PATCH context OPTIONS)

K J
  • 19
  • 2
  • Could you post the whole file and describe how you run your code? I just started REPL in terminal with compojure on classpath and it works. – Piotrek Bzdyl Mar 25 '16 at 16:59

1 Answers1

0

Clojure has methods require, import, refer, and use. These are for working with different namespaces.

:use is a Keyword, which can behave like a function (in your example it should return nil), but does not do what you want.

The confusion likely arises from the fact that inside the ns macro, you can 'embed' the behavior of these functions using the corresponding keywords.

For more reading on namespaces, see this link.

galdre
  • 2,319
  • 17
  • 31