K
Kaz Kylheku
(snip on call by reference, or not)
Assignment to i resulting in changing a variable in the caller,
is a feature of "pass by transparent/invisible reference"."Pass by explicit/visible reference" requires that a dereferencing
operator be applied to the reference to designate the caller's object
from which the reference was obtained.
So, the C [] operator is a visible dereference operator, but
the Fortran () (dummy array subscript) is not?
Ah, but in the case of arrays being passed around as a pointer
to the first element, this operator is used everywhere: by the
caller and callee alike.
It is not an operator which is inserted only in the called function
specifically to dereference the parameter.
Arrays in fact look like "pass by invisible reference". The invisibility comes
from the implicit array-to-pointer decay, and the way the array subscript works
on the reference just as well as on the array (so much so that all array
subscripting itself is defined that way). And further assisting the invisiblity
is that we can declare the function parameter using array syntax.
We call a function, giving the array as an argument: func(array).
In the function, we use the parameter as an array with subscripting,
and assignments to the element change the caller's array object.
It quacks almost like a duck, just with a slight goosey accent.
But C is different from Fortran in the need for * (or [0])
on scalar arguments.
Or the non-scalar argument case of an array being passed using a "pointer to
array"!