Skip to content

Assignment #19

@bvssvni

Description

@bvssvni

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions