[fpc-devel] Question on constref

Tomas Hajny XHajT03 at hajny.biz
Wed Feb 1 15:55:24 CET 2023


On 2023-02-01 15:40, 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 written above, the compiler can choose with const (and the choice may 
differ for different CPUs and other factors), i.e. you shouldn't make 
assumptions / rely on const of particular size to be passed by 
reference.

Tomas


More information about the fpc-devel mailing list