4 ms·
Sure. S-expressions[1] are a notation for nested data structures. They can be used to spell out data as well as code. In fact both code and data look the same w
by aaron-santos 10y ago
Sure. S-expressions[1] are a notation for nested data structures. They can be used to spell out data as well as code. In fact both code and data look the same when expressed using s-expressions.[2]
When the article's author describes both code and data using JSON, it sounds a little strange to me. While JSON is capable to describing nested data structures, JSON's syntax is much more verbose than s-expressions. I feel that since s-expressions have been around for about 60 years that the author should be familiar with them and address why a JSON encoding is superior to s-expressions for this use case.
1 - https://en.wikipedia.org/wiki/S-expression https://en.wikipedia.org/wiki/S-expression
2 - http://wiki.c2.com/?DataAndCodeAreTheSameThing http://wiki.c2.com/?DataAndCodeAreTheSameThing
- bijection 10y agoAlthough I'm also skeptical of coding in JSON, s-expressions are pretty close to a JSON subset (with the caveat that everything needs to be quoted). (x . (y . (z . NIL))) <=> ['x', ['y' , ['z', null]]]
- junke 10y agoThe first one is the flat list (x y z); the JSON one seems to be equivalent to (x (y (z nil))).
- bijection 10y agoYou're right! My scheme is rusty I guess. I should have said: (x . (y . (z . NIL))) <=> ['x', 'y', 'z']
- kazinator 10y agoIn Lisp, (x x x) denotes a list which contains three elements which are pointers to the same symbol object.