The current requirement for defining a data_readers.clj
at the source-path root makes creating libraries, that define reader-tags, cumbersome:
- Users need to paste the library reader-tags into their
data_readers.clj
- Maintainers won't want to use reader tags in the library's own source, because users might forget to paste them
- Shipping a
data_readers.clj
(like datomic does) bears the risk of libraries randomly clobbering each other (see lein-collisions)
- There is no clear way to reuse a safe subset of source data_readers as a default for the edn reader ...
- ... or even overriding them locally for a source-file/namespace
data_readers
(or a similar mechanism) need to be namespaced similar to source files. Here is a sketch proposal for how a __readers__.edn
file could be designed to alleviate the problems with data_readers
A __readers__
file should be in a globally project-unique subfolder. Each __readers__
file may define reader-tags that are namespaced to its containing namespace folder + they may define tags in sub-namespaces.
Overriding tags from parent namespaces is permitted, but should stay compatible if at all possible.
Each __readers__
file may propose a global shorthand alias with the ^tag-sym
metadata. For /datomic/__readers__.edn
this would look like
{^db/id datomic/id datomic.db-id-literal ...}
If the global shorthands of two tags collide, a warning is logged and the shorthand is deactivated.