On Fri, Feb 10, 2023 at 11:07 AM Sven Schreiber
<sven.schrei...@fu-berlin.de> wrote:
>
> 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?

Yes.

> So why would one ever use a pointer form along with "const"? Maybe it
> even should be banned?

The pointer-argument syntax preceded "const" in the development of
hansl. While the pointer form is now redundant when used with "const"
I don't see any reason to ban it. In a way the "redundant" form is
more explicit, making it clear that the argument will be passed by
reference, not by value.

> 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?

I guess that would work, but it's not the reason why const + pointer is allowed.

Allin
_______________________________________________
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