First Draft: Static Single Assignment

Peter C peterc at gmail.com
Wed Dec 3 10:16:42 UTC 2025


On Wednesday, 3 December 2025 at 08:34:23 UTC, Walter Bright 
wrote:
> On 11/27/2025 2:14 PM, Peter C wrote:
>> Compound assignment on a primitive type suggests an intention 
>> to mutate, not reassign. So to maintain conceptual 
>> consistency, compound assignments should also be allowed on 
>> 'final' primitive types.
>
> I agree with everything you wrote except that(!) I don't see a 
> reason to accept compound assignment with a `final` variable.

Actually I now disagree with my assertion as well ;-)

Compound assignment is always a reassignment, not a mutation:

final int i = 42;
i += 10; // Am I just changing the value here? No.

Step1: Calculate the right-hand side (RHS): i + 10 (which is 42 + 
10 = 52).

Step2: Assignment: Take the calculated value (52) and assign it 
back to the variable on the left-hand side (LHS): i = 52.

Since the variable i was declared final, it is only allowed one 
assignment statement in its scope.

The initial declaration final int i = 42; was the first 
assignment.

The operation i = 52; is the second assignment, and thus, it 
directly violates the single-assignment rule enforced by final.



More information about the dip.development mailing list