3 ms·
For people not already very familiar with S-expressions, a slightly different way to formulate and format the example from the post is: (sprites (sprite :x
by neilv 6y ago
For people not already very familiar with S-expressions, a slightly different way to formulate and format the example from the post is:
(sprites (sprite :x 32
:y 104
(animation :texture "assets/idle.bmp"
:frame-length 2
:frame-width 24
:frame-height 24
:frame-span 5
:loop 0)))
A benefit of formatting this way comes when it's not only a nested chain, like in this contrived example, but you have more varied tree structure, like in real-world code and data, and want to be able to grasp the nesting structure visually. And without using too many vertical lines of screen space.
- benrbray 6y agowhat is the advantage over something more standard like JSON?
- thelazydogsback 6y agoFor machine reading/writing, not much. For human reading/writing, sexprs (or Prolog terms) are much nicer as you don't need to quote everything, for example. However, (traditional) sexprs don't have defined literal map or vector/array syntax that's different from a list - for that you need an extension such as EDN format defined by Closure, but usable elsewhere.
- lokedhs 6y agoI'd say there are a few major benefits: 1. Distinction between symbols and strings. 2. A well-specified number format (integers are integers). In JSON the precision of a number is unspecified, not something you want from an interchange format. 3. It has comments. 4. It's more concise. 5. Easier to parse.