-
-
Notifications
You must be signed in to change notification settings - Fork 4
reference
A reference is an abstract handle to an object.
references in angle
see Variables for now
Wasp as data language can represent cyclic graphs through references independent of the consuming programming language ( like Angle).
TODO
Previous node_pointer can be referenced either via semantically meaningful id
field or by name using a special
reference
prefix $
.
This concept is WIP and subject to changing.
Ephemeral examples of a cyclic graph:
a {
b
c { parent=$a }
}
a[id=1]{
b
c { parent=$1 }
}
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