The Assignment in Language Specification

Assignment = ExpressionList assign_op ExpressionList .
assign_op = [ add_op | mul_op ] “=” .

The text later explains that “In assignment operations, both the left- and right-hand expression lists must contain exactly one single-valued expression”. So (if I interpret right) when add_op or mul_op is present then both ExpressionLists must be Expressions (not lists).

This could be expressed quite easily:

Assignment = TupleAssignment | AssignmentOperation .
TupleAssignment = ExpressionList “=” ExpressionList .
AssignmentOperation = Expression ( add_op | mul_op ) “=” Expression .

I would recommend to remedy the language specification text, if possible. Otherwise one can believe that i, j += 1, 2 should be, at least syntactically, correct. But it is not correct even syntactically, as the go compiler says: syntax error: unexpected +=, expecting := or = or comma.

Thanks for your input, however specification issues should be submitted at

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.