-
-
Notifications
You must be signed in to change notification settings - Fork 55
Closed
Labels
Description
Declaration syntax:
<left> := <right>
Mutable assignment syntax:
<left> ?= <right>
Where ?=
can be =
, +=
, *=
etc.
The following rules are used:
:=
does a shallow clone of right value, if it is a reference=
does a shallow clone of right value:=
ignores the type of the assigned item?=
checks the type of assigned item?=
does a shallow clone (copy-on-write) of left value before assigning, if it is a reference
The rules are designed for:
- Make numbers and booleans feel natural without the runtime distinguishing between copy and non-copy variables
- Allow sharing of objects, but with the ability to replace it with a non-shared object
- Copy-on-write behavior, where no simple assignment mutates an object elsewhere
- Avoid making variables entangled in surprising ways
- Prevent infinite cycles of references