Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upMutability design (`mut`) #112
Comments
bvssvni
added
draft
information
and removed
draft
labels
May 5, 2016
bvssvni
closed this
May 7, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bvssvni commentedMay 5, 2016
•
edited
Dyon uses
mutto declare mutability. This appears in front of a function argument declaration or when calling a function that mutates the argument.foo(mut a)mutates the argumentafoo(mut a)has function namefoo(mut)foo(mut a, b)has function namefoo(mut,_)foo(a, b)has function namefooLocal variables are mutable.
Mutability is not part of a type, but added to the function name inside parentheses, e.g.
(mut,_). When adding an external function, the mutability information must be added as part of the function name.Mutability propagates for arguments:
Multiple functions can use the same name if they have different mutability information. This reduces the need for "get", "set" and "mut" in function name:
This is designed for: