|
|
|
|
|
by sevensor
210 days ago
|
|
Suppose you have the EDN text (
{
:name "Fred"
:age 35
}
{
:name 37
:age "Wilma"
}
)
There's a semantic error here; the name and age fields have been
swapped in the second element of the list. At some point, somebody
has to check whether :name is a string and :age is a number. If your
application is going to do that anyway, why do syntax typing?
You might as well just try to construct a number from "Wilma" at the
point where you know you need a number.Obviously I have an opinion here, but I'm putting it out there in
the hope of being contradicted. The whole world seems to run on JSON,
and I'm struggling to understand how syntax typing helps with JSON
document validation rather than needlessly complicating the syntax. |
|
If you answer the first question with no, then the second question is revealed to just be about various considerations other than validation, such as legibility and obvious mapping to language types (such as having a common notation for symbols/keywords, sets, etc).
JSON and EDN are similar here, if your comment was in context of JSON vs EDN difference. There's some incidental additional checking on the syntax level with EDN but that's not its purpouse.
You can do interesting things with the data even if you don't parse/validate all of it.
Eg an important feature of the spec schema system and philosophy is that you don't want closed specs, you want code to be able to handle and pass on data that is richer than what the code knows about, and if circumstances allow you shouldn't try to validate it in one place.