On Fri, Feb 10, 2023 at 11:07 AM Sven Schreiber
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:
function void hugematrix1 (const matrix m)
function void hugematrix2 (const matrix *m) # note the pointer form
The second function wants a pointerized argument. Do I understand
correctly that in this case the difference has no real effect?
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.