Share your thoughts in the 2025 State of Clojure Survey!

Welcome! Please see the About page for a little more info on how this works.

+3 votes
ago in Syntax and reader by
edited ago by

Set up

Tagged literals are defined by setting a namespaced symbol in data_readers.clj (or data_readers.cljc). At load, Clojure merges all of the maps defined in data_readers.clj(c) files found on the classpath into a single map. At read time, the symbol following a # is checked in the merged data readers map, which determines which var to call with the contents of the following form.

For example, #foo/bar [1 2 3] leads to the reader calling the equivalent of (get *data-readers* 'foo/bar).

Problem statement

The tag of a tagged literal must be determined when it is created. The namespace of the chosen tag is set and cannot be changed by a user. Unlike a fully qualified symbol with an aliased namespace, a tagged literal must what was chosen by the author.

As an author of tagged literals, I want to write tags that will not clash with other tags by giving them complex/deep namespaces. For example, {noahtheduke.lazytest/expect noahtheduke.lazytest/expect}.

As a user of tagged literals, I want to alias the namespace of tags and use it in my code. For example:

;; in src/data_readers.clj
{noahtheduke.lazytest/expect noahtheduke.lazytest/expect}

;; in test/noahtheduke/example_project/main-test.clj
(ns noahtheduke.example-project.main-test
  (:require
   [noahtheduke.lazytest :as-alias lt]
   [noahtheduke.lazytest.core :refer [defdescribe it]]))

(defdescribe some-test
  (it "works"
    #lt/expect (= 1 2)))

EDN

This is not related to edn at all and any potential change will be to Clojure itself.

1 Answer

+1 vote
ago by

Logged as https://clojure.atlassian.net/browse/CLJ-2932

I reworded the title and problem as this slips into solution space (and I'm not sure that solution is even possible given the reader nature of the problem).

ago by
Crap, i was editing when it looks like you edited, so i think i overwrote your changes. No wait, you did that in the jira ticket, never mind!
ago by
I didn't edit it here, just on the jira.
...