Alias
In the heading of a function, each argument is a declaration
of a variable or an instance of class. You can view an argument as a copy
of an external object that is given to be processed by the function at beginning,
and that is destroyed when the function is ended.
Changes on the object has no effect on the original one when it is a variable.
This is not the case when it is an instance of a class: this is not a copy,
but the address of the original instance that is given to the function and
changes are in fact performed on the original object. It is possible, if required,
to use also the original of a variable, rather than a copy: thanks to the
"alias" keyword, the compiler knows that this is just another name for the
original variable.
A function without alias | void
myfun(int x) x + 100 print x return int y = 5 myfun(y) print y |
Display: | >>> 105 5 |
A function with alias | void
myfun(alias int
x) x + 100 print x return int y = 5 myfun(y) print y |
Display: | >>> 105 105 |