(I'm ignoring the comma operator, which is a special case and not relevant to the main point.)
(I'm ignoring the comma operator, which is a special case and not relevant to the main point.)
foo(x, -y)
is not the same as foo(x -y)
(from your last sentence, I assume you were talking about JS in general, not just JSON)Never mind.
Actually, let's double down: Instead of writing 1+2, you should really be writing +(1 2). Don't you see how much easier that would make things? A single, uniform syntax everywhere! + is just a function that gets called like anything else! Your foo(x -y) example would become foo(x -(y)).
I'm mostly joking.
Does use commas for lists and tuples, though. The latter kind-of make sense, it's the commas that identify the expression as a tuple. Not sure what the rationale for commas in lists is, though.
[1] Slightly complicated by currying (arguably, it's several successive function applications rather than one multi-arg application) but the end result is the same...
Well, you need some separator, and spaces won't do since [x y] has x applied to y.
Although could, in principle, make space-between-list-items higher precedence than function application. E.g.:
[x (func y) z] res = -x ==> negative x
res = c - x ==> c minus x
res = - x ==> syntax error foo(x -y) => foo(x, -y)
foo(x - y) => foo(x - y)