[fpc-devel] Question on constref

Michael Van Canneyt michael at freepascal.org
Wed Feb 1 15:54:30 CET 2023



On Wed, 1 Feb 2023, Hairy Pixels via fpc-devel wrote:

>
>
>> On Feb 1, 2023, at 8:27 PM, Michael Van Canneyt via fpc-devel <fpc-devel at lists.freepascal.org> wrote:
>> 
>> That's exactly what Adriaan is saying. With const the compiler can choose.
>> With constref, you force it not to copy. But this is not so efficient for
>> small parameter sizes.
>
> So const will always pass records that are over a certain size by
> references?  That’s good to know since “const” is more pleasant to look at
> it than constref.  :)

As I wrote: The compiler can choose. 
Whether it will always do what you think it should do is another matter.

It's not for no reason that constref was introduced: to leave the compiler no
choice...

Michael.


More information about the fpc-devel mailing list