When I define my function in the repl, it works as I expect. When I drop it into a namespace (i.e. my app) and reload the repl, I lose the namespace
component on the keyword. I am not sure what I am missing here.
;; Repl
(defn repl-keyword-gen [k str] (keyword (name k) str))
(repl-keyword-gen :test "example")
;;=> :test/example
;; App - example.core
(defn app-no-sym-keyword-gen [str] (keyword "test" str))
(defn app-with-sym-keyword-gen [k str] (keyword (name k) str))
(app-no-sym-keyword-gen "example")
;;=> :test/example
(app-with-sym-keyword-gen :test "example")
;;=> :example <----- Not sure about this one right here
Would appreciate insight/explanation into why this keyword builder returns different results.
Edited - screenshots
I think there may be a problem in your environment.
I tested using plain-old lein run
and got the namespaced keyword:
(ns clj.core
(:require
[tupelo.core :as t]
[clj-time.core :as tm]
))
(t/refer-tupelo)
;; App - example.core
(defn app-no-sym-keyword-gen [str] (keyword "test" str))
(defn app-with-sym-keyword-gen [k str] (keyword (name k) str))
(spyx (app-no-sym-keyword-gen "example"))
(spyx (app-with-sym-keyword-gen :test "example"))
(defn -main [& args]
(println "-main"))
Results:
~/clj > lein run
(app-no-sym-keyword-gen "example") => :test/example
(app-with-sym-keyword-gen :test "example") => :test/example
-main
To get the (spyx ...)
part to work, you need this in your project.clj:
:dependencies [
[tupelo "0.9.9"]
...