On Thu, 2 Feb 2023, Hairy Pixels via fpc-devel wrote:
On Feb 2, 2023, at 3:57 PM, Adriaan van Os via fpc-devel <fpc-devel@lists.freepascal.org> wrote: - under what circumstances (and in what compiler mode) does FPC pass large (say 1 MB or 1 GB) "const" parameters by value (which is extremely inefficient) ? - for what reasons ? As long as these questions are not addressed and cleared and documented "const" parameters are not a useable in actual code.That’s what I want to know. There should be a hard rule like records over X bytes are passed by reference. In the issue you posted they said they had a massive performance penalty in their library because const was passing by value and this makes people like myself paranoid so I’m inclined to use constref everywhere with larger records.
It depends on the platform ABI, and hence we don't document it. I don't see your problem, to be honest: You want to indicate a parameter to a function cannot be changed in its implementation. If you don't care about how it is passed, use const. If really want a reference to be passed for performance or other reasons, use constref. So you're doing the right thing by using constref. Couldn't be simpler. Michael.
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel