[fpc-pascal] readonly variables
Jonas Maebe
jonas.maebe at elis.ugent.be
Sun Nov 29 23:45:51 CET 2009
On 29 Nov 2009, at 22:59, Anthony Walter wrote:
>> Do you mean this one?
>>
>> "Using const allows the compiler to optimize code for structured- and
>> string-type parameters."
>>
>> "Allows" is not the same as "forces". This line in the help file does not
>> say that const parameters are passed by reference. It says that it may often
>> be so, perhaps all current implementations make it so, but it is by no means
>> guaranteed.
>
> Martin Schreiber also chimed in, pointing out:
>
> http://bit.ly/6uaAiB
>
> "Larger sets, records, and static arrays are passed as 32-bit pointers
> to the value."
I believe that the previous thread that's referred to above was about cdecl functions: http://lists.freepascal.org/lists/fpc-pascal/2009-November/023125.html
And the documentation you linked goes on to say:
"[Larger sets, records, and static arrays are passed as 32-bit pointers to the value.] An exception to this rule is that records are always passed directly on the stack under the cdecl, stdcall, and safecall conventions; the size of a record passed this way is rounded upward to the nearest double-word boundary."
So it seems that passing them by value actually corresponds to what the Delphi docs say.
Jonas
More information about the fpc-pascal
mailing list