-
Notifications
You must be signed in to change notification settings - Fork 3
References
Often times in object-oriented-languages, referencing rules are complicated and inconsistent. FastCode aims to provide a consistent, simple referencing system that also conforms to most programming practices.
When a value is passed by reference, that means the receiving variable's value will echo the value you passed by reference, and vice versa.
For example, if we set the variable a to a reference of the variable b,
a = ref b
and assign a value to a
a = 7
that same value has also been assigned to b and every other value that references either a or b.
print(b) //outputs 7
It also works the other way around. If we assign a value to b,
b = 13
it will also be assigned to a and every other value that references either a or b.
print(a) //outputs 13
Any procedure argument or value with a reference data type (see value types for further reading) gets passed by reference automatically. Otherwise (in the case of all primitives unless specified), each value is cloned beforehand.