Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, a couple of points:</p> <ol> <li>Macros are simply functions that receive as input [literals, symbols, or collections of literals and symbols], and output [literals, symbols, or collections of literals and symbols]. Arguments are never functions, so you could never directly check the function the symbol maps to.</li> <li><code>(call-special #(println % " World") "Hello")</code> contains reader macro code. Since reader macros are executed before regular macros, you should expand this before doing any more analysis. Do this by applying <code>(read-string "(call-special #(println % \" World\") \"Hello\")")</code> which becomes <code>(call-special (fn* [p1__417#] (println p1__417# "world")) "Hello")</code>.</li> </ol> <p>While generally speaking, it's not obvious when you would want to use something when you should probably use alternative methods, here's how I would approach it.</p> <p>You'll need to call <code>macroexpand-all</code> on <code>a</code>. If the code eventually becomes a <code>(fn*)</code> form, then it is guaranteed to be a function. Then you can safely emit (~a ~b). If it macroexpands to eventually be a symbol, you can also emit <code>(~a ~b)</code>. If the symbol wasn't a function, then an error would throw at runtime. Lastly, if it macroexpands into a list (a function call or special form call), like <code>(println ...)</code>, then you can emit code that uses the thread macro <code>-&gt;</code>.</p> <p>You can also cover the cases such as when the form macroexpands into a data structure, but you haven't specified the desired behavior.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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