Hi,
I'm asking for verification or falsification of my understanding how
arguments to functions are treated, specifically those (potentially)
involving a lot of memory. Consider these two similar functions:
<hansl>
function void hugematrix1 (const matrix m)
eval rank(m)
end function
function void hugematrix2 (const matrix *m) # note the pointer form
eval rank(m)
end function
</hansl>
The second function wants a pointerized argument. Do I understand
correctly that in this case the difference has no real effect? My
understanding is that when the arg has the "const" property, internally
gretl doesn't do a copy anyway. So in a way it's already involving a
memory pointer. And since with "const" the arg is immutable, it can't be
used as a way to grab the function's output, either.
So why would one ever use a pointer form along with "const"? Maybe it
even should be banned?
Well, there's one thing that I can imagine, but perhaps a little
far-fetched: The caller can pass an anonymous on-the-fly argument to the
non-pointerized form, but that isn't possible (AFAIK) with the
pointerized variant. So that could be a "clever" way for the function
author to force a named argument, for example to be able to use the
argname() function inside the user-written function. Is this the
background of this?
thanks
sven