I assume you are running in the repl. I do not see the behavior you describe:
clj.core=> (resolve 'someSymbol)
nil
clj.core=> (defn resolvePokus []
#_=> (prn "I was evaluated")
#_=> (def someSymbol 1)
#_=> )
#'clj.core/resolvePokus
clj.core=> (resolve 'someSymbol)
#'clj.core/someSymbol
; try to use it -> error "Unbound..."
clj.core=> someSymbol
#object[clojure.lang.Var$Unbound 0x542f6481 "Unbound: #'clj.core/someSymbol"]
clj.core=> (resolvePokus) ; run the function
"I was evaluated"
#'clj.core/someSymbol
clj.core=> (resolve 'someSymbol) ; still can resolve
#'clj.core/someSymbol
clj.core=> someSymbol ; now we can use it
1
clj.core=> (declare xyz) ; creates a var, but unbound
#'clj.core/xyz
clj.core=> (resolve 'xyz) ; we can see resolve it
#'clj.core/xyz
clj.core=> xyz ; try to use it -> error "Unbound"
#object[clojure.lang.Var$Unbound 0x2d1d436f "Unbound: #'clj.core/xyz"]
clj.core=> (def xyz 5) ; define it
#'clj.core/xyz
clj.core=> (resolve 'xyz) ; still can resolve
#'clj.core/xyz
clj.core=> xyz ; now we can use it
5
So when I define the function, after typing the final parentheses the repl prints that #'clj.core/resolvePokus
is defined but not someSymbol
. The final resolve
call still returns nil
.
However, if you read further it seems that Clojure does the equivalent of a (declare someSymbol)
when it first sees the (def someSymbol 1)
. You can see the same behavior when I manually (declare xyz)
and later give it a value via (def xyz 5)
You may wish to look at this answer. The details involve the "hidden" var and how it is the anonymous intermediary between the symbol xyz
and the value 5
.
P.S. The above example was run on Ubuntu 16.04, Clojure 1.8, Java 1.8