<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged metalanguage</title>
<link>https://ask.clojure.org/index.php/tag/metalanguage</link>
<description></description>
<item>
<title>`eval` using functions with metadata</title>
<link>https://ask.clojure.org/index.php/15115/eval-using-functions-with-metadata</link>
<description>&lt;p&gt;TIL:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(eval (list + 1 2)) ; works
(eval (list (var-get #'+) 1 2)) ; works
(eval (list (fn [a b] (+ a b)) 1 2)) ; works

(defmacro m [] `(~(fn [a b] (+ a b)) 1 2))
(m) ; also works

;; however, if the function has any metadata:
(eval (list (with-meta + {}) 1 2))
;; ^ fails, No matching ctor found for class clojure.lang.AFunction$1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This was unintuitive to discover.&lt;/p&gt;
&lt;p&gt;I solved it locally with a little helper:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn val-&amp;gt;expr [v]
  (if (symbol? v)
    `'~v
    (cond-&amp;gt; v
      (and (fn? v) (not (nil? (meta v))))
      (-&amp;gt; (with-meta nil)
          (list (-&amp;gt; v meta (update-vals val-&amp;gt;expr)))
          (conj `with-meta)))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But this takes special handling. I wonder if something similar would not be possible on a &quot;matching ctor&quot;-level, possibly also for &lt;code&gt;comp&lt;/code&gt;, &lt;code&gt;every-pred?&lt;/code&gt;, etc. It would be fairly trivial even in userland to have versions of these functions which carry metadata sufficient to recreate expressions, e.g. &lt;code&gt;comp&lt;/code&gt; storing the list of functions, and then &lt;code&gt;eval&lt;/code&gt;, on encountering &lt;code&gt;No matching ctor found for class clojure.core$comp$fn__5921&lt;/code&gt;, can instead pull out the list of functions from that value and evaluate &lt;code&gt;(list* comp (:composed-fns (meta v)))&lt;/code&gt; (or some such) instead.&lt;/p&gt;
&lt;p&gt;I think this would be great to have in the core lib, at least for metadata and core libs functions like &lt;code&gt;comp&lt;/code&gt;, &lt;code&gt;some-fn&lt;/code&gt;, &lt;code&gt;every-pred?&lt;/code&gt;, and &lt;code&gt;complement&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Note, I'm not talking about adding or changing ctors for these necessarily. A hook for taking unconstructable values and making a constructable value out of them would serve just as well, maybe even a multifn.&lt;/p&gt;
&lt;p&gt;Strictly in userland and without core lib support, I suppose the cleanest way to do something like this is a custom protocol and probably monkeypatch some core libs functions (maybe &lt;code&gt;eval&lt;/code&gt;?)&lt;/p&gt;
&lt;p&gt;So I suppose my questions are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Is this something you agree would be good to have in general? Or is this by design for some reason I can't see?&lt;/li&gt;
&lt;li&gt;Would this be good and practical to have in the corelib? Oughtn't be a breaking change at least&lt;/li&gt;
&lt;li&gt;If no, is there currently any sane way to apply my solution in a more systemic way than wrapping every relevant value with a &lt;code&gt;val-&amp;gt;expr&lt;/code&gt; call?&lt;/li&gt;
&lt;/ol&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15115/eval-using-functions-with-metadata</guid>
<pubDate>Mon, 01 Jun 2026 14:33:00 +0000</pubDate>
</item>
<item>
<title>Adding support for byte sequences to the EDN standard</title>
<link>https://ask.clojure.org/index.php/11019/adding-support-for-byte-sequences-to-the-edn-standard</link>
<description>&lt;p&gt;How do I get support for byte sequences to EDN?  One implementation might be from adopting the mechanism used by Bencode: &lt;a rel=&quot;nofollow&quot; href=&quot;https://wiki.theory.org/index.php/BitTorrentSpecification#Bencoding&quot;&gt;https://wiki.theory.org/index.php/BitTorrentSpecification#Bencoding&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This still requires some context and doesn't allow for top level direct arbitrary binary to be accepted as valid.  I'm not sure this is the best method, but I do need some way to represent arbitrary binary blobs well.   One thing to also consider is interrupted data, which bencode's approach does not work well with.  That might always be an application level concern, I'm not sure.&lt;/p&gt;
</description>
<category>Contrib libs</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11019/adding-support-for-byte-sequences-to-the-edn-standard</guid>
<pubDate>Tue, 07 Sep 2021 23:30:50 +0000</pubDate>
</item>
<item>
<title>What do the metalanguage-style symbols on clojuredocs.org mean?</title>
<link>https://ask.clojure.org/index.php/10707/what-do-the-metalanguage-style-symbols-clojuredocs-org-mean</link>
<description>&lt;p&gt;I want to know what the characters mean on the second lines of entries on &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojuredocs.org&quot;&gt;https://clojuredocs.org&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For example, head on over to &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojuredocs.org/clojure.core/prn&quot;&gt;https://clojuredocs.org/clojure.core/prn&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The first line of that page is:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;prn
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The second line is:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(prn &amp;amp; more)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What does &lt;code&gt;(prn &amp;amp; more)&lt;/code&gt; mean? How do I interpret that? In particular, how do I interpret the ampersand &lt;code&gt;&amp;amp;&lt;/code&gt;?&lt;/p&gt;
&lt;p&gt;The notation used here reminds me of the &quot;metalanguage&quot; Augmented Backus-Naur form (&lt;a rel=&quot;nofollow&quot; href=&quot;https://en.wikipedia.org/wiki/Augmented_Backus%E2%80%93Naur_form&quot;&gt;https://en.wikipedia.org/wiki/Augmented_Backus–Naur_form&lt;/a&gt;), used to express the grammar of a programming language, and of the usage guidance often given by help entries for programs.&lt;/p&gt;
&lt;p&gt;However, I don't see any documentation anywhere of how to interpret this particular metalanguage, if that's even what's going on here.&lt;/p&gt;
&lt;p&gt;I am especially wondering how to interpret the &lt;code&gt;&amp;amp;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If there is a page somewhere explaining this, I wish it were linked from every entry on &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojuredocs.org&quot;&gt;https://clojuredocs.org&lt;/a&gt;.&lt;/p&gt;
</description>
<category>Docs</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10707/what-do-the-metalanguage-style-symbols-clojuredocs-org-mean</guid>
<pubDate>Sat, 19 Jun 2021 15:32:03 +0000</pubDate>
</item>
</channel>
</rss>