<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions in Namespaces and vars</title>
<link>https://ask.clojure.org/index.php/questions/clojure/namespaces-and-vars</link>
<description></description>
<item>
<title>best way to conditionally def a symbol and do some side effect if symbol does not exist?</title>
<link>https://ask.clojure.org/index.php/12934/best-conditionally-symbol-some-side-effect-symbol-does-exist</link>
<description>&lt;p&gt;I was surprised that this code in dev/user.clj doesn't run at start up:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns user) ; user ns is loaded by REPL startup

(println &quot;Evaluating dev/user.clj&quot;)
(when-not (resolve 'xxx)
  (def xxx 1)
  (println &quot;defing xxx&quot;))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This worked for me:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defonce yyy (let [tmp 1] (println (str &quot;deffing yyy as &quot; tmp))
                   tmp))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Something like this was also suggested to me in the clojurians &lt;br&gt;
 [https://clojurians.slack.com/archives/C053AK3F9/p1683882344251029][Slack] :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns user)

(when-not (resolve 'xxx)
  (intern 'user 'xxx 42)
  (prn &quot;!!!&quot;))
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Namespaces and vars</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12934/best-conditionally-symbol-some-side-effect-symbol-does-exist</guid>
<pubDate>Fri, 12 May 2023 10:38:38 +0000</pubDate>
</item>
<item>
<title>Need help adding Membrane library to project</title>
<link>https://ask.clojure.org/index.php/12641/need-help-adding-membrane-library-to-project</link>
<description>&lt;p&gt;I'm trying my first project with Membrane and it doen't look like I'm doing this right.&lt;/p&gt;
&lt;p&gt;I create a test leiningen project.&lt;/p&gt;
&lt;p&gt;I set the project.clj file dependancies to:&lt;/p&gt;
&lt;p&gt;  :dependencies [[org.clojure/clojure &quot;1.11.1&quot;]
  				[com.phronemophobic/membrane &quot;0.11.1.1-beta&quot;]]&lt;/p&gt;
&lt;p&gt;Added this to the top of the core.clj file:&lt;/p&gt;
&lt;p&gt;(ns MyProj.core&lt;br&gt;
  (:require [membrane.ui :as ui])&lt;br&gt;
  (:gen-class))&lt;/p&gt;
&lt;p&gt;I also pasted in some basic membrane code I found and kept the &quot;-main&quot; function.&lt;/p&gt;
&lt;p&gt;I saved the file. &lt;br&gt;
Ran &quot;lein deps&quot; from the command line. Lots of stuff loaded.&lt;/p&gt;
&lt;p&gt;I open the Lein repl (lots of stuff loads) and see that the prompt is set to the name space.&lt;br&gt;
I try running the &quot;-main&quot; function but get an error.&lt;/p&gt;
&lt;p&gt;MyProj.core=&amp;gt; (-main)&lt;br&gt;
Syntax error compiling at (/private/var/folders/m0/4krjx9mj4mx6p4zc4m372cv80000gn/T/form-init4189431604337866983.clj:1:1).&lt;br&gt;
Unable to resolve symbol: -main in this context&lt;/p&gt;
&lt;p&gt;What went wrong and how can I fix this?&lt;br&gt;
Thanks in advance!&lt;/p&gt;
&lt;p&gt;J&lt;/p&gt;
</description>
<category>Namespaces and vars</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12641/need-help-adding-membrane-library-to-project</guid>
<pubDate>Sat, 04 Feb 2023 20:00:41 +0000</pubDate>
</item>
<item>
<title>Need help using Slurp &amp; JSON</title>
<link>https://ask.clojure.org/index.php/12603/need-help-using-slurp-json</link>
<description>&lt;p&gt;I'm completely new with Clojure and I'm trying to do some basic stuff with Slurp and JSON.&lt;/p&gt;
&lt;p&gt;I found some code (doesn't work) that I'm using as an example to try to learn some basics.&lt;br&gt;
The following code is supposed to get some JSON data from Ipinfo.io and then pull JUST the City name from it and print it.&lt;br&gt;
I'm getting so many errors with the namespaces that I can't even get to testing the actual code. :-(&lt;/p&gt;
&lt;p&gt;Any help would be GREATLY appreciated !  :-)&lt;br&gt;
Jason&lt;/p&gt;
&lt;p&gt;(ns my-namespace&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(:require [clojure.core :as core]
			[clojure.data.json :as json]))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(defn get-city [ip-addr]&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(let [resp (core/slurp (str &quot;https://ipinfo.io&quot; ip-addr &quot;/json&quot;))
	city-name (-&amp;gt;&amp;gt; resp 
			(json/read-str)
			:city)]
(core/prn city-name)
city-name))
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Namespaces and vars</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12603/need-help-using-slurp-json</guid>
<pubDate>Mon, 30 Jan 2023 18:52:14 +0000</pubDate>
</item>
<item>
<title>&quot;namespace X is required but never used&quot; but uberjar compiles and runs it anyway?</title>
<link>https://ask.clojure.org/index.php/12506/namespace-required-never-used-uberjar-compiles-runs-anyway</link>
<description>&lt;p&gt;So... to be quick, this is my core.clj file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns ffmpeg-in-a-jar.core
  (:gen-class)
  (:require [ffmpeg-in-a-jar.encoder :as encoder]))

(defn -main
  &quot;ffmpeg autoencoder made with Clojure&quot;
  [&amp;amp; args]
  (println &quot;Files will begin encoding...&quot; ))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;on encoder.clj file i've defined an user-defined loop counter:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn loop-cnt []
  (println &quot;How many files to encode?&quot;)
  (def loopnum (read-string (read-line)))
  (println &quot;\n&quot;&quot;Files ready to encode&quot;))

(loop-cnt)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;it is right after used in a loop to again request the user for more input:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn queue []
  (loop [loopnum loopnum
         file-queue []]
   (if (not= loopnum 0)
     (do
       (def file-queue [])
       (println &quot;\n&quot;&quot;Write filenames one by one&quot;)
       (def add-queue (read-line))
       (recur (dec loopnum) (conj file-queue add-queue)))
     file-queue)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;im calling these with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(loop-cnt)
(def queue-result (queue))
(println &quot;\n&quot;&quot;Added to the Encoding Queue:&quot; &quot;\n&quot; queue-result &quot;\n&quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The real doubt im having is, how in the world is encoder even working, i use require to make it available but i've yet to call it inside -main with i guess should be:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(encoder/loop-cnt)
(println &quot;\n&quot; &quot;Added to the Encoding Queue:&quot; &quot;\n&quot; encoder/queue-result &quot;\n&quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;is the ns macro doing something im unaware of?&lt;/p&gt;
</description>
<category>Namespaces and vars</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12506/namespace-required-never-used-uberjar-compiles-runs-anyway</guid>
<pubDate>Sun, 25 Dec 2022 01:35:35 +0000</pubDate>
</item>
<item>
<title>Potential race condition in requiring-resolve?</title>
<link>https://ask.clojure.org/index.php/12346/potential-race-condition-in-requiring-resolve</link>
<description>&lt;p&gt;Hello! I've been using a few of the functions from &lt;code&gt;clojure.tools.build.api&lt;/code&gt; in a &lt;code&gt;future&lt;/code&gt; and I sporadically see this error...&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Execution error (IllegalStateException) at clojure.tools.build.api/create-basis (api.clj:154).
Attempting to call unbound fn: #'clojure.tools.build.tasks.create-basis/create-basis
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;From what I see in tools.build...&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn create-basis
  ([]
   ((requiring-resolve 'clojure.tools.build.tasks.create-basis/create-basis)))
  ([params]
   ((requiring-resolve 'clojure.tools.build.tasks.create-basis/create-basis) params)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;...the code is only really using &lt;code&gt;requiring-resolve&lt;/code&gt; to execute another function. Diving deeper into &lt;code&gt;requiring-resolve&lt;/code&gt; I can see that the first call to &lt;code&gt;resolve&lt;/code&gt; is not synchronized with the same lock that the &lt;code&gt;serialized-require&lt;/code&gt; function uses...&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn- serialized-require
  [&amp;amp; args]
  (locking clojure.lang.RT/REQUIRE_LOCK
    (apply require args)))

(defn requiring-resolve
  [sym]
  (if (qualified-symbol? sym)
    (or (resolve sym)
        (do (-&amp;gt; sym namespace symbol serialized-require)
            (resolve sym)))
    (throw (IllegalArgumentException. (str &quot;Not a qualified symbol: &quot; sym)))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;First, is it possible &lt;code&gt;requiring-resolve&lt;/code&gt; is actually returning &lt;code&gt;clojure.lang.Var$Unbound&lt;/code&gt; from the first call to &lt;code&gt;resolve&lt;/code&gt; when another thread is in the process of requiring that namespace via &lt;code&gt;serialized-require&lt;/code&gt;? Assuming so, should &lt;code&gt;tools.build&lt;/code&gt; (and I guess by extension most Clojure code) avoid using the &lt;code&gt;((requiring-resolve 'some-other/function))&lt;/code&gt; pattern? Is it possible &lt;code&gt;requiring-resolve&lt;/code&gt; could be modified to be thread safe?&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
</description>
<category>Namespaces and vars</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12346/potential-race-condition-in-requiring-resolve</guid>
<pubDate>Mon, 31 Oct 2022 05:20:05 +0000</pubDate>
</item>
<item>
<title>Namespace and :local/root path question</title>
<link>https://ask.clojure.org/index.php/12180/namespace-and-local-root-path-question</link>
<description>&lt;p&gt;Going through the intro tutorial with the suggested project structure.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;├── time-lib
│   ├── deps.edn
│   └── src
│       └── hello_time.clj
└── hello-world
    ├── deps.edn
    └── src
        └── hello.clj
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The file &lt;code&gt;time-lib/hello-world/deps.edn&lt;/code&gt; is referencing &lt;code&gt;:local/root&lt;/code&gt; as such: &lt;code&gt;{:deps
 {time-lib/time-lib {:local/root &quot;../time-lib&quot;}}}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;When I invoke &lt;code&gt;clj -X hello/run&lt;/code&gt; &lt;br&gt;
from the following directory:  &lt;code&gt;~/projects/hello-world&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Then my I get a result with the current time as expected.&lt;/p&gt;
&lt;p&gt;However, if I go up a level and invoke the same command from: &lt;code&gt;~/projects/&lt;/code&gt;, then I receive an error: &lt;br&gt;
`Namespace could not be loaded: hello&lt;/p&gt;
&lt;p&gt;Is this really a failure to 'load' the namespace? In which case I would like to know how to enforce an absolute path onto :local/root, or is it a failure to find the &lt;code&gt;hello.clj&lt;/code&gt;?&lt;/p&gt;
&lt;p&gt;When I try and help &lt;code&gt;clj&lt;/code&gt; to find the file by invoking &lt;code&gt;clj -X hello-world/hello/run from the &lt;/code&gt;projects/` directory, I still get a namespace error.&lt;/p&gt;
&lt;p&gt;I've checked some documentation, but it appears light on how this is supposed to work. &lt;/p&gt;
</description>
<category>Namespaces and vars</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12180/namespace-and-local-root-path-question</guid>
<pubDate>Thu, 08 Sep 2022 09:45:57 +0000</pubDate>
</item>
<item>
<title>How can I have a clj REPL namespace be the same as the namespace defined in my file.clj?</title>
<link>https://ask.clojure.org/index.php/11441/how-have-repl-namespace-the-same-the-namespace-defined-file</link>
<description>&lt;p&gt;I am using Emacs/Cider to launch a &lt;code&gt;clj&lt;/code&gt; REPL. I do this by first opening my file which defines a new namespace. I then use &lt;code&gt;cider-jack-in-clj&lt;/code&gt; to launch the REPL. The REPL namespace is “user”. I can only use fully qualified functions within the REPL. If I enter &lt;code&gt;user=&amp;gt; (ns myns)&lt;/code&gt; in the REPL, this works and changes the namespace as expected. I would like to automate this so that every time I launch a REPL from a file the REPL namespace changes as well.&lt;/p&gt;
&lt;p&gt;Alternatively, I am ok not changing the namespace as long as I can use unqualified functions.&lt;/p&gt;
&lt;p&gt;Here is an example from the top of my file, core.clj&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns coresync.core
(:use [tupelo.core])
(:require [clojure.core.async :refer [chan &amp;gt;!! &amp;lt;!!]]))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Within the emacs buffer for the code, I am able to get all the unqualified functions, but within the REPL, I need to use:&lt;/p&gt;
&lt;p&gt; &lt;code&gt;user=&amp;gt; clojure.core.async/chan&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;I’ve searched online and through this forum, but I haven’t been able to figure this out. I’m sorry in advance if this has already been asked and I missed it.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
</description>
<category>Namespaces and vars</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11441/how-have-repl-namespace-the-same-the-namespace-defined-file</guid>
<pubDate>Fri, 07 Jan 2022 18:47:07 +0000</pubDate>
</item>
<item>
<title>Are as-alias circular dependencies ok?</title>
<link>https://ask.clojure.org/index.php/11431/are-as-alias-circular-dependencies-ok</link>
<description>&lt;p&gt;:as-alias doesn't do any of the circular dependency checks that the other ways of using :require do. So it would appear that circular dependencies are fine, however contrib tools like tools.namespace still do the circular dependecy even for :as-alias forms, and throw errors when they are encountered. &lt;/p&gt;
</description>
<category>Namespaces and vars</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11431/are-as-alias-circular-dependencies-ok</guid>
<pubDate>Tue, 04 Jan 2022 21:38:22 +0000</pubDate>
</item>
<item>
<title>Help me understand the var basics in Clojure.</title>
<link>https://ask.clojure.org/index.php/11234/help-me-understand-the-var-basics-in-clojure</link>
<description>&lt;p&gt;We know that when we send a symbol to REPL, Clojure will resolve the symbol to var, and get the value which is currently the var's bindings. And we also know that var object is stable when it is interned by namespace, so we can dynamically modify the runtime behavior of a program(by re-def-ing the var's bindings).&lt;br&gt;
But here comes a strange things that I don't understand.&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://drive.google.com/file/d/1HaqwYCRFiKs9ZvJrK33RsIZgNGZSxvap/view&quot;&gt;Screenshot of the REPL process&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (ns ns-a)
ns-a=&amp;gt; (def a 42)
ns-a=&amp;gt; a
;;42
ns-a=&amp;gt; (ns ns-b)
ns-b=&amp;gt; (refer 'ns-a)
ns-b=&amp;gt; a
;;42
ns-b=&amp;gt; (var a)
#'ns-a/a
ns-b=&amp;gt; (in-ns 'ns-a)
ns-a=&amp;gt; a
;;42
ns-a=&amp;gt; (def a 99)
ns-a=&amp;gt; a
;;99
ns-a=&amp;gt; (in-ns 'ns-b)
ns-b=&amp;gt; a
;;99
;;nothing special so far
ns-b=&amp;gt; (in-ns 'ns-a)
ns-a=&amp;gt; (ns-publics *ns*)
;;{a #'ns-a/a}
;;see, it's interned
ns-a=&amp;gt; (ns-unmap *ns* 'a)
;;lets unmap the (var a) from ns-a
ns-a=&amp;gt; (ns-publics *ns*)
;;{}
ns-a=&amp;gt; a
;;Syntax error compiling at (REPL:0:0).
;;Unable to resolve symbol: a in this context
ns-a=&amp;gt; (var a)
;;Syntax error compiling var at (REPL:1:1).
;;Unable to resolve var: a in this context
;;(var a) is nowhere.
ns-a=&amp;gt; (in-ns 'ns-b)
ns-b=&amp;gt; a
;;99
;;the referred symbol a still evaluates to 99.
ns-b=&amp;gt; (var a)
;;#'ns-a/a
;;yeah, (var a) is still somewhere.
ns-b=&amp;gt; (deref (var a))
;;#object[clojure.lang.Var$Unbound 0x4a68135e &quot;Unbound: #'ns-a/a&quot;]
;;What? (var a) is being unbound. Is this a new (var a)?
ns-b=&amp;gt; a
;;99
;;it is not resolved from (var a)?
ns-b=&amp;gt; (in-ns 'ns-a)
ns-a=&amp;gt; a
;;#object[clojure.lang.Var$Unbound 0x4a68135e &quot;Unbound: #'ns-a/a&quot;]
;;What? it comes back?
ns-a=&amp;gt; (def a 53)
;;Lets redefine (var a) to bind 53
ns-a=&amp;gt; a
;;53
ns-a=&amp;gt; (in-ns 'ns-b)
;;Lets switch back and check.
ns-b=&amp;gt; a
;;99
;;not changed
ns-b=&amp;gt; (deref (var a))
;;53
;;so I'm sure 99 it is not resolved from (var a).
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;The first question&lt;/strong&gt;: where is the value 99 resides? It used to being resolved from #'a, but it seems being like a lexical bindings after #'a being unmapped. Is it?&lt;br&gt;
&lt;strong&gt;The second question&lt;/strong&gt;: why the #'a is interned back with unbound state after execute (var a) in another namespace(which has a refering to #'a)? Seems it create a new var to fullfill the state.&lt;/p&gt;
</description>
<category>Namespaces and vars</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11234/help-me-understand-the-var-basics-in-clojure</guid>
<pubDate>Mon, 01 Nov 2021 06:25:40 +0000</pubDate>
</item>
<item>
<title>Why is 'def' not implemented with a macro?</title>
<link>https://ask.clojure.org/index.php/9748/why-is-def-not-implemented-with-a-macro</link>
<description>&lt;p&gt;Clojure core language is small. More advanced syntax tends to be implemented using macros expanding to a handful of core special forms. One of the special symbols is &lt;code&gt;def&lt;/code&gt;, used for interning &lt;code&gt;Vars&lt;/code&gt; in the current namespace. Yet, there's also &lt;code&gt;intern&lt;/code&gt; that does virtually the same thing (bar the choice of ns) and is implemented with a mere function and some interop.&lt;/p&gt;
&lt;p&gt;Why does &lt;code&gt;def&lt;/code&gt; deserve a special form? Are there use-cases &lt;code&gt;def&lt;/code&gt; makes possible that couldn't be achieved with &lt;code&gt;intern&lt;/code&gt; and some more interop or macros?&lt;/p&gt;
</description>
<category>Namespaces and vars</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9748/why-is-def-not-implemented-with-a-macro</guid>
<pubDate>Mon, 02 Nov 2020 10:19:20 +0000</pubDate>
</item>
<item>
<title>What has happened to Immutable Namespaces?</title>
<link>https://ask.clojure.org/index.php/9421/what-has-happened-to-immutable-namespaces</link>
<description>&lt;p&gt;There used to be a Road Map that told us what might be in Clojure's  future. Immutable Namespaces was on the list . The idea seemed promising. &lt;/p&gt;
&lt;p&gt;The Road Map has vanished. &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Has the prospect of Immutable Namespaces vanished with it?&lt;/li&gt;
&lt;li&gt;Is this a resource problem? Would Cognitect/Clojure accept funding to&lt;br&gt;
do it?&lt;/li&gt;
&lt;li&gt;Is there anywhere else where Clojure's future is discussed?&lt;/li&gt;
&lt;/ul&gt;
</description>
<category>Namespaces and vars</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9421/what-has-happened-to-immutable-namespaces</guid>
<pubDate>Mon, 06 Jul 2020 14:45:30 +0000</pubDate>
</item>
<item>
<title>How do you diagnose the cause of slow (25min) app startup time?</title>
<link>https://ask.clojure.org/index.php/9357/how-do-you-diagnose-the-cause-of-slow-25min-app-startup-time</link>
<description>&lt;p&gt;I run my clojure app on the server directly from a git repo with the clojure CLI.  I'm struggling with a problem where it takes ~5-25 mins to startup in a virtual server and ~1 min on my laptop.  During this time there's almost no CPU usage and little of the 4GB of RAM is used.  I'm wondering if this is some kind of lock condition.  It seems like it's probably related to a dep since I don't remember it doing this in the past.  What are some ways to diagnose what's wrong?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ time clojure -A:server -e &quot;(require 'riverdb.server)&quot;
WARNING: requiring-resolve already refers to: #'clojure.core/requiring-resolve in namespace: datomic.common, being replaced by: #'datomic.common/requiring-resolve
    
real	24m49.555s
user	1m58.976s
sys	0m3.672s
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I tried the solution at &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/guides/dev_startup_time&quot;&gt;https://clojure.org/guides/dev_startup_time&lt;/a&gt;,  which I thought helped, but if I run it multiple times the delay varies widely:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ time clojure -A:dev:server -e &quot;(require 'riverdb.server)&quot;

real	5m19.167s
user	0m29.084s
sys	0m1.724s

$ time clojure -A:dev:server -e &quot;(require 'riverdb.server)&quot;

real	19m53.558s
user	0m31.972s
sys	0m1.988s
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Namespaces and vars</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9357/how-do-you-diagnose-the-cause-of-slow-25min-app-startup-time</guid>
<pubDate>Wed, 03 Jun 2020 22:55:45 +0000</pubDate>
</item>
<item>
<title>How to locate a function when debugging?</title>
<link>https://ask.clojure.org/index.php/9234/how-to-locate-a-function-when-debugging</link>
<description>&lt;p&gt;Our server is experiencing memory leaking. As to investigate what  happened, I used &lt;code&gt;jmap&lt;/code&gt; to dump JVM and got the following file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;No dump file specified
 num     #instances         #bytes  class name (module)
-------------------------------------------------------
   1:        904887       79630056  java.lang.reflect.Method (java.base@13.0.2)
   2:        935204       50874608  [Ljava.lang.Object; (java.base@13.0.2)
   3:        889710       47099400  [B (java.base@13.0.2)
   4:         85795       26006880  [C (java.base@13.0.2)
   5:        518846       22286056  [I (java.base@13.0.2)
   6:        781108       18746592  java.lang.String (java.base@13.0.2)
   7:        382891       15315640  java.math.BigInteger (java.base@13.0.2)
   8:        370774       14830960  java.math.BigDecimal (java.base@13.0.2)
   9:        153329       12266320  java.lang.reflect.Constructor (java.base@13.0.2)
...
 152:          1665         146520  java.util.regex.Pattern (java.base@13.0.2)
 153:          3638         145520  com.newrelic.agent.deps.org.objectweb.asm.tree.LdcInsnNode
 154:          9043         144688  exchange.api.restful.orders$fn__48874$fn__48879
 155:          9043         144688  exchange.api.restful.orders$fn__48874$fn__48881
 156:          9043         144688  exchange.api.restful.orders$fn__48874$fn__48883
 157:          9043         144688  exchange.api.restful.orders$fn__48874$fn__48885
 158:          9043         144688  exchange.api.restful.orders$fn__48874$fn__48887
 159:          9043         144688  exchange.api.restful.orders$fn__48874$fn__48892
 160:          9006         144096  java.util.Formatter$Flags (java.base@13.0.2)
 161:          8973         143568  java.util.concurrent.atomic.AtomicBoolean (java.base@13.0.2)
...
 600:           296           7104  java.math.MathContext (java.base@13.0.2)
 601:           221           7072  java.lang.invoke.BoundMethodHandle$Species_L (java.base@13.0.2)
 602:           221           7072  java.lang.invoke.LambdaForm$NamedFunction (java.base@13.0.2)
 603:           438           7008  clojure.core$distinct$step__6413
 604:           291           6984  taoensso.nippy$read_kvs_into$fn__36561
 605:           218           6976  sun.nio.fs.UnixPath (java.base@13.0.2)
 606:           218           6976  taoensso.carmine.protocol.EnqueuedRequest
 607:           173           6920  java.nio.channels.ClosedChannelException (java.base@13.0.2)
 608:           431           6896  clojure.core.async.impl.ioc_macros$return_chan$fn__21752
 609:           287           6888  javax.management.ImmutableDescriptor (java.management@13.0.2)
...
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So as you might interpret from it, it is an API service. And judging from the number of instances, I decided &lt;code&gt;exchange.api.restful.orders$fn__48874$*&lt;/code&gt; is bad. (Or I am wrong. My colleague suggested redis went wrong.)&lt;/p&gt;
&lt;p&gt;But here then goes the question: which function/api is it? How can I locate it?&lt;/p&gt;
</description>
<category>Namespaces and vars</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9234/how-to-locate-a-function-when-debugging</guid>
<pubDate>Mon, 13 Apr 2020 05:30:06 +0000</pubDate>
</item>
<item>
<title>Do clojure variables have Lisp-like properties?</title>
<link>https://ask.clojure.org/index.php/8870/do-clojure-variables-have-lisp-like-properties</link>
<description>&lt;p&gt;I'm taxed with porting a &lt;em&gt;mess&lt;/em&gt; of old Lisp code into the 21st century.&lt;br&gt;
I came across Clojure and think maybe it might be the avenue of best approach.&lt;br&gt;
I am an absolute newbie to Clojure.&lt;/p&gt;
&lt;p&gt;The Lisp code makes extensive use of symbol property lists.&lt;br&gt;
Do Clojure symbols have property lists? Or something that &quot;works&quot; as a property list?&lt;/p&gt;
&lt;p&gt;In Lisp, I could say:&lt;/p&gt;
&lt;p&gt;(put 'fly 'verb 'transitive)   ; The Verb property of &quot;fly&quot; is &quot;transitive&quot;.&lt;br&gt;
--&amp;gt; 'transitive&lt;br&gt;
(put 'fly 'noun '(a buzzing little bug))  ; The Noun property of &quot;fly&quot; is &quot;a buzzing little bug&quot;&lt;br&gt;
--&amp;gt; (a buzzing little bug)&lt;br&gt;
(get 'fly 'verb)  ; Show me the Verb property of &quot;fly&quot;&lt;br&gt;
--&amp;gt; transitive&lt;br&gt;
(symbol-plist 'fly)  ; Show me all the properties of &quot;fly&quot;&lt;br&gt;
--&amp;gt; (verb transitive noun (a buzzing little bug))&lt;/p&gt;
&lt;p&gt;Does Clojure support symbol property-lists?&lt;/p&gt;
</description>
<category>Namespaces and vars</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8870/do-clojure-variables-have-lisp-like-properties</guid>
<pubDate>Wed, 20 Nov 2019 15:03:29 +0000</pubDate>
</item>
<item>
<title>How to detect auto namespace in keyword ?</title>
<link>https://ask.clojure.org/index.php/8625/how-to-detect-auto-namespace-in-keyword</link>
<description>&lt;p&gt;I'm serializing a data structure with pr-str that may have keywords with auto namespace &lt;/p&gt;
&lt;p&gt;I would like to reduce the data structure not to contain auto keywords before serialization, but I don't know how to detect it?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(def x ::outbound)

(pr-str x) =&amp;gt; &quot;::outbound&quot;

(edn/read-string &quot;::outbound&quot;) =&amp;gt; exception

(namespace x) =&amp;gt; &quot;current-namespace&quot; 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;so is there a way to know that x has auto namespace ?&lt;/p&gt;
&lt;p&gt;thank you,&lt;/p&gt;
&lt;p&gt;Sorry - wrote the question without running it on repl - a proper example here&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(keyword &quot;:out&quot;) =&amp;gt; ::out

(pr-str (keyword &quot;:out&quot;)) =&amp;gt; &quot;::out&quot;

(edn/read-string (pr-str (keyword &quot;:out&quot;))) =&amp;gt;

Execution error at user/eval93457 (form-init751239350220000799.clj:1).
Invalid token: ::out
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Namespaces and vars</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8625/how-to-detect-auto-namespace-in-keyword</guid>
<pubDate>Fri, 20 Sep 2019 12:53:00 +0000</pubDate>
</item>
<item>
<title>Remove unused Var.rev</title>
<link>https://ask.clojure.org/index.php/2384/remove-unused-var-rev</link>
<description>&lt;p&gt;Var.rev is unused. The usage that does exist is not synchronised correctly.&lt;/p&gt;
&lt;p&gt;Alex suggested it be removed in this discussion;&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://groups.google.com/forum/#!topic/clojure-dev/idsFYAKnTPc&quot;&gt;https://groups.google.com/forum/#!topic/clojure-dev/idsFYAKnTPc&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The attached patch removes rev from Var.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Screened:&lt;/strong&gt; Alex Miller&lt;/p&gt;
</description>
<category>Namespaces and vars</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/2384/remove-unused-var-rev</guid>
<pubDate>Wed, 03 Jan 2018 16:12:11 +0000</pubDate>
</item>
<item>
<title>Lighter-weight aliasing for keywords</title>
<link>https://ask.clojure.org/index.php/2817/lighter-weight-aliasing-for-keywords</link>
<description>&lt;p&gt;It is useful to make qualified keywords, and particularly so with spec. Using namespace aliases helps a lot in working with a lot of qualified keywords. However, currently creating an aliased namespace requires that the namespace actually exists.&lt;/p&gt;
&lt;p&gt;This ticket is a placeholder to do something more with lighter-weight aliasing for keywords. Details TBD.&lt;/p&gt;
</description>
<category>Namespaces and vars</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/2817/lighter-weight-aliasing-for-keywords</guid>
<pubDate>Fri, 10 Mar 2017 14:12:28 +0000</pubDate>
</item>
<item>
<title>Suppress warnings when clojure.core symbols are explicitly replaced with &quot;use&quot; or &quot;refer&quot;</title>
<link>https://ask.clojure.org/index.php/3357/suppress-warnings-clojure-symbols-explicitly-replaced-refer</link>
<description>&lt;p&gt;Problem: Libraries that provide DSLs (such as core.matrix) often replace or extend functions in core (such as &quot;+&quot;, &quot;==&quot;, &quot;zero?&quot;), since it is desirable to use the best / most idiomatic names.&lt;/p&gt;
&lt;p&gt;Currently importing such libraries with &quot;use&quot; causes unwanted warnings like &quot;WARNING: + already refers to: #'clojure.core/+ in namespace: test.blank, being replaced by: #'clojure.core.matrix/+&quot;. &lt;/p&gt;
&lt;p&gt;Avoiding these warnings requires extra user effort and boilerplate code, which is frustrating for users since they have already explicitly asked for the full library to be imported into the current namespace (i.e. via &quot;use&quot; or &quot;:refer :all&quot;).&lt;/p&gt;
&lt;p&gt;Proposed solution is to introduce a new var &lt;strong&gt;warn-on-replace&lt;/strong&gt; similar to &lt;strong&gt;warn-on-reflection&lt;/strong&gt; which allows this warning to be controlled.&lt;/p&gt;
</description>
<category>Namespaces and vars</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/3357/suppress-warnings-clojure-symbols-explicitly-replaced-refer</guid>
<pubDate>Sat, 07 Sep 2013 04:33:49 +0000</pubDate>
</item>
</channel>
</rss>