Re:SVG: The Good, the Bad and the Ugly
by renox on Saturday February 13, 2021 @02:47PM
(#26126149)
I know you're joking but I still don't understand why (+ x y) is a good idea: clearly the first argument has a different meaning than the other, IMHO +(x y) show better the difference between the operation a d the arguments..
[ Parent
| on HN ]
Re:SVG: The Good, the Bad and the Ugly
by tadfisher on Saturday February 13, 2021 @11:38PM
(#26129727)
That significantly complicates the grammar, as now nested function calls require context from their parent to form an AST node. S-exps are the literal representation of the AST which allows for easily modifying and inspecting code, for example through macros. It's not so much "the first element is significant", it's more like "this is the convention of what a function looks like so you can pass it around and modify it as a single list".
I'm only half joking. The different notations all have pros and cons, but the benefit of s-expressions are their simplicity. A list can be either an expression (+ x y) but can also be a list of things like (red blue green) and an empty list can be written as (). It is basically the simplest possible structured notation.
+(x y) would be fine for expressions but weird for lists of things.