"a = b operator c" syntax

(Note: I am not proposing any nested expressions! Just the exact syntax in the title, with operator being one of +-*/.)

PulpScript already supports syntax where an assignment is combined with a function, like in
a = frame x,y
a = round b
so there is no reason why
a = b + c
shouldn't be possible as well.

a + b is just as much of a function call as something like frame x,y (takes two inputs and returns one output), so to be consistent with these, syntax like a = b + c should also be supported. No nested expressions, no parentheses, only a variable receiving the sum/difference/product/quotient of exactly two values and nothing else, just so the language can be less inconsistent with its own rules. It's something newcomers are often confused by (and remains annoying to more experienced coders), but the confusion is entirely understandable, because a = frame x,y being allowed while a = b + c isn't makes little sense.

(Heck, if syntax parsing is too big of an issue to make this happen, even something like a = add b,c would do imo. It has the advantages of using an existing syntax and making it more obvious that nesting is not allowed)

1 Like

The primary reason for its omission is as you’ve guessed, the (reasonable) expectation that if a + b works then compound expressions like a + b + c or (a + b) * c and even deeper nesting should also work.

I think your alternative proposal addresses that concern nicely (and is actually how it is implemented under the hood already).

1 Like