On 10.02.2023 17:07, Sven Schreiber wrote:
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.
True.
So why would one ever use a pointer form along with "const"? Maybe it
even should be banned?
But why? Even in C there is a lot of "redundand" statements involving
pointers (char[] is a classics here).
Marcin
--
Marcin Błażejowski