Zeynel
Zeynel

Reputation: 13525

CompilerException java.lang.RuntimeException: Unable to resolve symbol: - [Clojure]

I have this save-message function in guestbook.models.db namespace and I am trying to run it in the repl but I get this:

guestbook.models.db> (save-message "A" "Hi"
                                   )
CompilerException java.lang.RuntimeException: Unable to resolve symbol: save-message in this context, compiling:(/private/var/folders/xc/ypy3lqhj08xg2hjc6g81qwl80000gn/T/form-init7598384514150426113.clj:1:1) 

I reload and try again and I get the same error

guestbook.models.db> (:reload 'guestbook.models.db)
nil
guestbook.models.db> (save-message "A" "Hi"
                                   )
CompilerException java.lang.RuntimeException: Unable to resolve symbol: save-message in this context, compiling:(/private/var/folders/xc/ypy3lqhj08xg2hjc6g81qwl80000gn/T/form-init7598384514150426113.clj:1:1) 
guestbook.models.db> 

What am I doing wrong?

Upvotes: 5

Views: 4543

Answers (1)

Michał Marczyk
Michał Marczyk

Reputation: 84379

You want to say

(require :reload 'guestbook.models.db)

This reloads this single namespace; if you use :reload-all instead, it will also recursively reload all namespaces loaded by guestbook.models.db, directly or indirectly.

See (doc require) for details.


As for (:reload 'guestbook.models.db):

Keywords in Clojure, when used as functions, attempt to treat their first argument as a map to look themselves up in. For example, (:foo {:foo 1}) returns 1. If this argument cannot be so treated, nil is returned. Optionally a second argument can be provided, to be returned as the default value in case the keyword fails to find a value corresponding to itself in its first argument (whether it happens to be a non-map or a map which has no entry for this key).

Upvotes: 6

Related Questions