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

_______________________________________________
Gretl-devel mailing list -- gretl-devel@gretlml.univpm.it
To unsubscribe send an email to gretl-devel-le...@gretlml.univpm.it
Website: 
https://gretlml.univpm.it/postorius/lists/gretl-devel.gretlml.univpm.it/

Reply via email to