[fpc-pascal] How to avoid Copy

Sven Barth pascaldragon at googlemail.com
Wed Jan 3 07:32:31 CET 2024


Am 01.01.2024 um 16:51 schrieb Wayne Sherman via fpc-pascal:
> On Mon, Jan 1, 2024 at 6:14 AM Hairy Pixels wrote:
>>> On Jan 1, 2024, at 3:50 PM, Michael Van Canneyt wrote:
>>> You can't optimize that. As said, a generic is convenient but slow.
>> I don't know about that. Like was mentioned the enumerator needs to return a
>> pointer, preferable without ^ so it feels like a record and only use that in the for-in
>> scope. You can kind of do that yourself but it's cumbersome to maintain and
>> missing from the RTL (maybe for this reason).
> Modern Pascal compilers already do this for certain types and pass by
> reference parameters.  For example, AnsiString variables and variables
> of type class are handled internally as pointers, but manipulated
> opaquely without explicit pointer notation.  A record passed as a var
> or constref parameter is internally a pointer, but does not require
> the code writer to handle it explicitly as such.
That kind of concept only exists in Pascal for parameters, but not for 
variables or result values as would be needed for this.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20240103/f5708305/attachment.htm>


More information about the fpc-pascal mailing list