<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Adriaan van Os via fpc-devel <<a href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>> schrieb am Do., 2. Feb. 2023, 09:57:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Sven Barth wrote:<br>
> Adriaan van Os via fpc-devel <<a href="mailto:fpc-devel@lists.freepascal.org" target="_blank" rel="noreferrer">fpc-devel@lists.freepascal.org</a> <br>
> <mailto:<a href="mailto:fpc-devel@lists.freepascal.org" target="_blank" rel="noreferrer">fpc-devel@lists.freepascal.org</a>>> schrieb am Do., 2. Feb. 2023, <br>
> 02:47:<br>
> <br>
> Sven Barth via fpc-devel wrote:<br>
> <br>
> > There is no full documentation for that parameter modifier (someone<br>
> > might want to file a bug report for that), but the documentation for<br>
> > “const” (<br>
> ><br>
> <a href="https://www.freepascal.org/docs-html/current/ref/refsu67.html#x183-20700014.4.4" rel="noreferrer noreferrer" target="_blank">https://www.freepascal.org/docs-html/current/ref/refsu67.html#x183-20700014.4.4</a><br>
> <br>
> > ) contains this:<br>
> ><br>
> > === doc begin ===<br>
> ><br>
> > Contrary to Delphi, no assumptions should be made about how const<br>
> > parameters are passed to the underlying routine. In particular, the<br>
> > assumption that parameters with large size are passed by<br>
> reference is<br>
> > not correct. For this the constref parameter type should be used,<br>
> which<br>
> > is available as of version 2.5.1 of the compiler.<br>
> ><br>
> > === doc end ===<br>
> <br>
> On debate, see FPC issue 17442.<br>
> <br>
> <br>
> There is no debate planned for this in the near future. So even if this <br>
> might change some time in the future it does not *now* and very likely <br>
> also not for 3.4.0. Not to mention that things wouldn't change for most <br>
> platforms anyway, because they only have the platform ABI available and <br>
> that *must not* change for compatibility with C code. <br>
<br>
"Will not change" and "ABI" are non arguments. They do not address the questions put forward here:<br>
<br>
- under what circumstances (and in what compiler mode) does FPC pass large (say 1 MB or 1 GB) <br>
"const" parameters by value (which is extremely inefficient) ?<br>
- for what reasons ?<br>
<br>
As long as these questions are not addressed and cleared and documented "const" parameters are not <br>
a useable in actual code.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">We do not document these on purpose, because they're mainly dictated by the platform ABI (on the majority of targets FPC supports simply the C ABI is used). The main part of "const" is that you can't (easily) modify the value and that reference counting isn't done when passing the value around. Whether it's passed by-value or by-reference is irrelevant for that. </div><div dir="auto">If you need pass-by-reference then use those modifiers that are intended for them, namely "var", "out" and "constref". </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>