[fpc-pascal] Copy dynamic array

denisgolovan denisgolovan at yandex.ru
Wed May 16 18:10:14 CEST 2018


> What would the expected behavior be for pointers inside records? What if
> the record is actually a linked list? Or includes classes and objects?
> Do we run the constructor or no? If the record has file handles do we
> attempt to recreate their state? (perhaps running assign again, and
> crossing our fingers the file hasn't been deleted - which at least on
> Linux is definitely possible)

Well.
The answer is simple - value types (scalars, strings, records, variants, arrays of mentioned) are good functional citizens.
Cloning is well defined for them as compound value is also value. 

Should someone wants for add complexity (read OOP/pointers/classes and other crap) - use http://wiki.freepascal.org/management_operators#Copy at your own risk.

-- 
Regards,
Denis Golovan



More information about the fpc-pascal mailing list