Octave does copy on write. So passing variables anywhere does not
duplicate it, be it an assignment or a passing to a function. Only right
before the first change the variable gets duplicated.
So you can pass that big value as often as you want to if you don't
change it. This might not be as good as having references, but it's
quite decent anyway. You could try that using a very simple recursion.
BTW: Does Octave notice that it can operate on the passed arguments
directly? Matlab states to notice that in
var = foo(var)
the variable 'var' can be manipulated directly, thus saving speed and
To revisit this, partially repeating myself: I believe it's inevitable
that at least one (deep) copy of the array is made if an arbitrary
interpreted function is executed. Otherwise, the array can't be
reliably left unchanged if an error occurs in the function.
At the link you've given it is stated (if I understood it correctly)
that for the 'behaviour' to work the function must have been called by
another function. This would _not_ suffice in Octave to generate an
'outer' (deep) copy of the array, but maybe they have some mechanism
in Matlab to do this in this way.
Since (as I think) one copy must be generated anyway, I think you
could achieve equivalent behavior in Octave for operations (algebraic
operations or basic function calls) which change only certain
(indexed) elements of an array: Perform all such operations within one
function -- then a copy of the whole array should only be generated at
the first of these operations.
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net