On Wed, 1 Feb 2023, Sven Barth via fpc-devel wrote:

Am 01.02.2023 um 11:30 schrieb Bart via fpc-devel:
I thought that constref would be OK for that (the word constref
suggests to me tah the paramter will be treated (by me) to be a
constant, and that it shall be passed by reference in all cases,
whereas with a const parameter the compiler decides upon the best way
to pass it: by value or by reference).
I tried to find documentation for constref, but all I could find was:
https://wiki.freepascal.org/FPC_New_Features_2.6.0#Constref_parameter_modifier
There it says:
"Note that in general, it should only be used for interfacing with
external code or when writing assembler routines."

“constref” is guaranteed to pass the parameter by reference. And the compiler will ensure that it can't be modified as reasonably possible (as with “const” there are ways to circumvent this, e.g. by passing around a pointer to the parameter, but the general cases are covered).
(B.t.w.: Where can I find the official documentation on constref?)

There is no full documentation for that parameter modifier (someone might want to file a bug report for that), but the documentation for “const” ( https://www.freepascal.org/docs-html/current/ref/refsu67.html#x183-20700014.4.4 ) contains this:

No need for a bugreport, this already is changed in trunk docs:

https://www.freepascal.org/daily/doc/ref/refsu68.html#x184-20800014.4.4

Michael.
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to