Psychophanta wrote:What Fred will say is that '@' prefixed pointers (i.e. variables finally) can not be written with new values, but just the '*' prefixed ones.
Yes, '@' is an operator to get the address of something (variables, procedures). The '@' operator is read-only,
so '@var = 12' is not supported. It does not make sense to change the address of an 'object' with the '@' operator.
.
'*' is used for readable and writeable pointer variables. To get the address of the pointer, you use the '@' operator, for example 'x = @*pointer',
and again, the address of the variable '*pointer' is read-only. You can't change the address of the variable '*pointer' in memory.
It is just the pointer variable itself that is readable and writeable.
Swap works with pointer variables:
Code: Select all
Define *pointer1 = 1, *pointer2 = 2
Debug *pointer1
Debug *pointer2
Swap *pointer1, *pointer2
Debug *pointer1
Debug *pointer2
Swapping the addresses of the pointer variables would not make sense:
Code: Select all
Define *pointer1 = 1, *pointer2 = 2
Debug @*pointer1
Debug @*pointer2
Swap @*pointer1, @*pointer2
Debug @*pointer1
Debug @*pointer2
Pointers and the '@'-address-operator are not the same.