3 ms·
> {"p2":{"x":141,"y":85},"mode":"line","p1":{"x":34,"y":44}} Embracing ordered rather than named parameters can make this so much cleaner (that’s why most folk
by eadmund 1y ago
> {"p2":{"x":141,"y":85},"mode":"line","p1":{"x":34,"y":44}}
Embracing ordered rather than named parameters can make this so much cleaner (that’s why most folks would prefer add(1, 2) to {"function":"add", "augend": 1, "addend": 2}). It’s strange that p2 comes before p1.
["line",{"x":34,"y":44},{"x":141,"y":85}]
The same argument applies to points — way name their components when they will always be the same?
["line",[34,44],[141,85]]
If you’re willing to abandon JSON, you can make it even cleaner. There’s no real need for quotes around the mode:
[line,[34,44],[141,85]]
And it’d be nice to have some whitespace:
[line, [34, 44], [141, 85]]
And come to think of it, those commas don’t really add anything:
[line [34 44] [141 85]]
Hmmm, if you switched from brackets to parentheses I bet you have a library which could handle this for you:
(line (34 44) (141 85))
- xigoi 1y agoAny sufficiently complicated C or Fortran program…