-
-
Notifications
You must be signed in to change notification settings - Fork 4
reference
Pannous edited this page Sep 15, 2021
·
4 revisions
TODO Variables are referenceIndices to values. peter=person#2
One needs to distinguish between changing the reference and changing the value of the reference. (In c this is achieved via *x=7 or int &y=… y=8).
In angle this might be achieved with special keywords reference
or value
or inout
:
peter=person#2
peter=person#3 // changing reference
value of peter=James // now person#3 is charged to James (following reference)
person#3=John // now peter points to John too (reference following)
As in swift, reference is the standard modus operandi, only when attributes are charged will a true copy occur : Swift doesn't copy until there's a mutation or the possibility of mutation.
Internal usage:
Special hardwired ternary operators: array#position=value, list[index]=value, data[pattern]=value, condition?then:else The first cases can be handled via references