4 ms·
> OTOH you kind of need hashes/maps in the real world Well, plists (foo bar baz quux) and alists ((foo . bar) (baz . quux)) or ((foo bar) (baz quux)) have prov
by zeveb 11y ago
> OTOH you kind of need hashes/maps in the real world
Well, plists (foo bar baz quux) and alists ((foo . bar) (baz . quux)) or ((foo bar) (baz quux)) have provided good enough functionality for quite a long time.
> And Unicode.
S-expressions can be Unicode: (edelweiß) is a perfectly valid s-expression.
> And standard representations for the base datatypes.
Common Lisp's extensively documented reader algorithm[1] contains standard read forms for symbols, strings, characters lists, integers, rational numbers, floats, complex numbers, pathnames, structs, comments, vectors, arrays, bitfields as well as some miscellaneous other types.
There's no reason that it couldn't be augmented with something like #{} for hashes (although this would require updating the standard: currently, those characters are reserved for the user; maybe #H{} instead?), #D"2015-12-01" for dates, #U"http://www.example.com/" http://www.example.com/" for URLs and so forth.
This:
#{(title "Example Scheme")
(type "object")
(properties #{(first-name #{(type string)})
(last-name ${(type string)})
(age ${(description "Age in years")
(type integer)
(minimum 0)})})
(required #(first-name last-name))}
seems a lot nicer to my eyes than:
{
"title": "Example Schema",
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"description": "Age in years",
"type": "integer",
"minimum": 0
}
},
"required": ["firstName", "lastName"]
}
[1] http://www.lispworks.com/documentation/lw70/CLHS/Body/02_b.htm http://www.lispworks.com/documentation/lw70/CLHS/Body/02_b.h...
- kabdib 11y agoEither of the above are tons better than XML. JSON is fine, but as you point out, things could be better.