Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment #19

Closed
bvssvni opened this issue Jan 31, 2016 · 0 comments
Closed

Assignment #19

bvssvni opened this issue Jan 31, 2016 · 0 comments

Comments

@bvssvni
Copy link
Member

bvssvni commented Jan 31, 2016

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant