Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>user=> (def l '(a 1 2)) user=> ((first l))</p> </blockquote> <p>Turn this into:</p> <blockquote> <p>user=> (def l `(~a 1 2))</p> </blockquote> <p>The ~ here resolves the symbol a to its corresponding var, and the backtick makes unquoting work.</p> <p>In general, you must understand the difference between vars (which are bound to something) and symbols (which are never bound to anything).</p> <p>I'll try to explain it (in the hope that my exaplanation does not confuse you further):</p> <pre><code>user=&gt; (def v "content") #'user/content </code></pre> <p>-> defines a var in the current namespace under the symbol 'v (fully qualified 'user/v, assuming this is the current namespace), and binds it (the var, not the symbol) to the object "content".</p> <pre><code>user=&gt; v "content" </code></pre> <p>-> resolves v to the var, and gets the bound value</p> <pre><code>user=&gt; #'v #'user/v </code></pre> <p>-> resolves to the var itself</p> <pre><code>user=&gt; 'v v </code></pre> <p>-> does not resolve anything, just a plain symbol (unfortunately, the REPL does not indicate this, printing 'v as v)</p> <pre><code>user=&gt; `v user/v </code></pre> <p>-> as you already quoted, resolves to the symbol in the current context (namespace), but the result is still a symbol (fully qualified), not the var user/v</p> <pre><code>user=&gt; '(v) (v) </code></pre> <p>-> plain quoting, does not resolve anything</p> <pre><code>user=&gt; `(v) (user/v) </code></pre> <p>-> syntax-quote, same as quoting, but resolves symbols to namespace-qualified symbols</p> <pre><code>user=&gt; `(~v) ("content") </code></pre> <p>-> resolve the symbol to its var (which is implicitely dereferenced), yielding its bound object</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload