Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How are consumers supposed to handle values with unrecognized tags? #80

Open
ethanresnick opened this issue Sep 29, 2018 · 1 comment
Open

Comments

@ethanresnick
Copy link

Is there some standard behavior that makes sense to have as the default? E.g., ignoring the tag, ignoring the value, erroring, etc.

@ethanresnick ethanresnick changed the title How are consumers supposed to handle values with unrecognized tags How are consumers supposed to handle values with unrecognized tags? Sep 29, 2018
@claj
Copy link

claj commented Apr 23, 2020

When reading in the clojure reader the reader fails when it reads an unknown tag.

(clojure.edn/read-string "#unknown-tag [1 2 3]")
;; => Exception: No reader function for tag unknown-tag

You can, however give the reader a default tag, like tagged-literal

(clojure.edn/read-string {:default tagged-literal} "#unknown-tag [1 2 3]")
;; => #unknown-tag [1 2 3]

But this tagged litteral (of class clojure.lang.TaggedLiteral) has no particular meaning inside your application, it just serializes to the same thing as it was read as.

So, no, there is no sane default here. If your application is unaware of the meaning of the data it shuffles around, fine, use tagged-litteral, otherwise you better give your EDN-reader the nescessary tag->function-mapping to parse the data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants