Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 327
Zeynel Avatar asked Dec 29 '13 19:12

Zeynel


1 Answers

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).

like image 113
Michał Marczyk Avatar answered Sep 23 '22 06:09

Michał Marczyk