edn-format / edn Goto Github PK
View Code? Open in Web Editor NEWExtensible Data Notation
Extensible Data Notation
In the explanation for Symbols it says, "non-numeric character" and "alphanumeric characters." Are those restricted to ASCII or can relevant Unicode fit?
The wikipedia page for 'alphanumeric' states that it is commonly restricted to Latin Letters and Arabic Digits, but then makes exception for 'other locales.'
Unless I'm mistaken, there's no actual implementation at https://github.com/agentultra/pyedn.
This is a follow-up to the recent commit clojure/clojure@88cad25.
Currently, bpsm/edn-java rejects the symbol foo//
. I suspect now that this is not correct behavior.
commit 88cad2510243289d2bbe28cf8bd14007d9df5fc3
Author: Chris Gray <[email protected]>
Date: 2011-11-09 22:23:15 -0700
Allow foo// meaning the function / in namespace foo
Added regression tests
Signed-off-by: Stuart Halloway <[email protected]>
I'd like to start contributing samples for a conformance suite. I have an accepted CA - should I just submit a pull request to this project?
Is the newline that terminates a ; comment platform dependant or is it strictly \newline?
Two specific areas: Single-line comments and Characters.
It might be helpful for implementations to have the ability to state exactly what version of the spec they conform to.
'Though this might only be most useful as the spec solidifies and likely won't be useful after the final BNF is published - assuming the definition of Edn is stable after that.
Most languages will interpret "\r" as a literal escape code in the input stream.
Common Lisp solves this problem by representing characters as #\r
(char "r" 0)
> #\r
Which would make parsing input easier.
The spec says about symbols that "/
by itself is a legal symbol" and continues that "[k]eywords follow the rules of symbols, except they can (and must) begin with a colon, e.g. :fred
or :my/fred
". So :/
seems to be a valid keyword. Is this intended?
Suppose you have defined the #x/table tag which takes a list with a header and rows to increase a little the readability and diminish the data length:
#x/table ((:name :surname :age)
("bob" "smith" 33)
("miles" "davis" 83)
)
This tag will yield the list ({:name "bob" :surname "smith" :age 33}, {:name "miles" :surname "davis" :age 83}). My question is: can you give this output value as an input to another tag handler? Like by doing:
#x/othertag #x/table ((:name :surname :age)
("bob" "smith" 33)
("miles" "davis" 83)
)
By reading the EDN spec I think is not clear if you can compose tags or not, maybe the phrase "This value is the value to be returned to the program and is not further interpreted as edn data by the reader." prohibits it.
So, will the reader pass the value returned by the #x/table handler as the input of the #x/othertag handler? That will be nice, in any case needs to be clear in the spec if is permitted or not.
Do Symbols beginning with a plus have the requirement that the second character be non-numeric?
The / character is valid in the middle of a Symbol.
Is ./. a valid Symbol? Other questionable Symbols: -/.
Is the rule that the / character may not appear at the end or beginning of a Symbol with more than one character? Is the middle anywhere but the end or beginning of a Symbol with more than one character (which would make sense)? Does this imply the restriction that prefix and name are not allowed to be empty (which would make sense)?
The Clojure reader currently does not allow periods in tagged literals (see http://dev.clojure.org/jira/browse/CLJ-1100). The EDN spec is unclear on this issue:
edn supports extensibility through a simple mechanism. # followed immediately by a symbol starting with an alphabetic character indicates that that symbol is a tag.
Are periods allowed in tags?
There isn't a clear definition of digit. It seems to include 0-9, which would make leading zeros valid for both integer and float.
Does the : fulfill the beginning of a Symbol where the / must be in the middle of a Symbol?
It'd be nice to have it right there when newcomers see the Readme.
Can a tag handler return non-edn data? Is the return required to be a single edn element?
Escaping of double quotes and backslashes in strings is not specified at all.
I would assume that:
"foo\\bar"
=> foo\bar
"foo\"bar"
=> foo"bar
And the clojure implementation confirms this. It should be specified in edn though.
It's not clear to me if "#_ #_ 1 2 3" is equivalent to "#_ 1 #_ 2 3". This is the case in Clojure's LispReader, but I thought I'd ask to be certain.
(One could argue for "#_ #_ 1 2 3" being equivalent to "1 2 3" if the first #_ were to eat the second.)
Greater than and less than aren't in the symbols section and I would like some clarification. Can you have greater than and less than in tags in edn?
According to the edn spec, symbols can begin with an underscore. ("Symbols begin with a non-numeric character and can contain alphanumeric characters and . * + ! - _ ?. If - or . are the first character, the second character must be non-numeric. Additionally, : # are allowed as constituent characters in symbols but not as the first character.")
Tags are symbols prefixed with a pound sign. Therefore, you could have a tag like this: #_cnd/my-snazzy-tag
.
#_
is a reader macro used to discard the next value, however. In this case, instead of my tag, I discard the symbol cnd/my-snazzy-tag
, which is not what I want.
Should there be a special rule eliminating underscores as the first character of a tag? Or should this be handled a different way?
Is #prefix/name42 valid edn? Does it become the tag #prefix/name applied to the element 42?
Will other symbols be allowed in Symbol?
I'm thinking of: ~ ` @ $ % ^ & + = | \ < >
I'd love in particular: | and %
I noticed that the relevance/edn-ruby lib is supporting metadata e.g.
^{:doc "This is my vector" :rel :temps} [98.6 99.7]
Is this going to be part of the official edn spec? At the very least I can imagine suggesting that languages which do not have support for metadata can treat it as a comment/discard?
The regex at https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/EdnReader.java#L28-L30 allows for octal, hex, and arbitrary base (e.g. 3r2011012) ints.
Is the edn definition incomplete or is the clojure EDN reader too liberal?
I follow forbidding "-4bar" since that means potentially unbounded look-ahead to distinguish numbers from non-numbers.
Presumably forbidding ".4bar" is for the same reason, though ".1" doesn't appear to be a valid numeric literal. (Numeric literals all start with a digit.)
The floating point numbers states:
64-bit (double) precision is expected.
The integers definition should have an analog statement.
e.g. something like
64-bit (signed integer) precision is expected.
E.g. a Java consumer might call unmodifiableList when making lists, etc. ?
When reading in certain numbers ("0.309222940550554E56687886556350", for example), I end up with Infinity in my target language (Ruby). Should I output these as Double/POSITIVE_INFINITY or Double/NEGATIVE_INFINITY, or are numbers of this size unsupported?
Since whitespace is not significant, I might assume that it is allowed.
Would [a b foo #_ 42] => [a b foo] ?
Specifically, are the delimiters for a Set in the group that, "need not be separated from adjacent elements by whitespace?"
The delimiters () {} and [] are already mentioned... should #{ be added as not needing leading whitespace?
As per discussion: https://groups.google.com/d/topic/clojure-dev/a4PHSIFXNt0/discussion
Is an empty stream or file valid edn?
"If - or . are the first character, the second character must be non-numeric. Additionally, : # are allowed as constituent characters in symbols but not as the first character."
So, is "foo/-4bar" allowed or not? It would seem allowed, but this has the unfortunate property that the we're left with an unreadable symbol if we strip the prefix: "-4bar".
If not, then which slash marks the division between prefix and base name?
I assume that character literals are intended to be like those in Clojure, however these are legal in Clojure:
\<an actual space>
\<an actual newline>
\<an actual return>
\<an actual tab>
I don't think it would be a good idea to support these in edn as they are hard for a human to read unambiguously. I'd suggest requiring:
\space
\newline
\return
\tab
...
and disallowing whitespace immediately following the \ introducing a
character literal.
The "floating point numbers" section refers to 64-bit double precision -- presumably IEEE-754 -- and specifies how to encode typical numbers, but it does not specify encoding of special values such as NaN or infinities. This is undesirable, as now any object graph that includes any IEEE-754 floating point field could conceivably become unserializable, depending on the value that field contains.
JSON makes no allowances for NaN or +/-Inf, forcing tools to use tricks like serializing these values as strings, and coercing certain strings ("NaN") back into their floating-point counterparts on deserialization. Not only does this add semantics on an ad-hoc basis outside the JSON specification, it is simply too much magic for my taste. On the other hand, YAML provides .inf
, -.Inf
, and .NAN
as language-independent tokens representing these particular floating point values. I find this much preferable, as it causes no ambiguity.
I'd like the encoding of these values to be specified, since edn seems to be aiming at general-purpose data interchange, and the set of floating point numbers includes these special values.
the mandatory leading : of keywords is disallowed for symbols..
Considering EDN is a simpler XML, can we also get a simpler XSD?
David Nolen and I were discussing the potential for formalizing the ClojureScript AST. My first thought was that I wish I had an AST validator, like the ASTValidator.java in Google Closure. My next thought was "I'm sure core.logic could make this very easy". I typed not more than two sentences of notes on this topic before I thought: This smells an awful lot like XML Schemas...
What about an ordered map syntax? Many XML applications use the implicit definition order, maybe using ordered maps is better than using lists for some tasks.
Would be nice.
I found the clisp page on constituent, and that seems to mean that the related character is valid for that element in edn. Is that correct?
I'm confused about where : and # are valid in Symbols. Clearly they can be 'in' a Symbol, and not the first character. The Clojure Reader page says that Symbols ending with : are reserved by Clojure - is that also true of edn? That same Clojure Reader page says that : must be non-repeating. Is that true in edn of : and #?
Is there a high probability of a built-in tag for regex?
isn't that much shorter than
I'm just curious.
application/edn
should probably be appropriate, no?
The proposed grammar for floating point numbers does not allow: "1M" since at least a frac or exp part is required following the int part. Clojure does allow this. Is this deliberate?
Any plans for adding EDN to the IANA registry of media types?
http://www.iana.org/assignments/media-types/index.html
Am I correct to assume that only the 3 escape sequences \t \r \n are supported in EDN strings? Seems to not be complete since escaped double quotes are so common?
Hi Rich,
Have you heard of any iOS frameworks for parsing/generating EDN?
If not, I might do one for myself (and open sourcing it afterwards).
Best,
Henrik
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.