[fpc-pascal] Dynamic arrays using management operators
Sven Barth
pascaldragon at googlemail.com
Wed Jun 6 23:25:04 CEST 2018
Nitorami <mneubauer at alice-dsl.net> schrieb am Mi., 6. Juni 2018, 22:39:
> >2) dynamic arrays can index directly into records and write to fields but
> the [] operator overload can’t do this.
>
> I don't understand this, can you provide an example ?
>
With dynamic arrays that contain records you can do this:
=== code begin ===
var
parr: array of TPoint;
begin
// init parr
// ...
parr[0].x := 42;
end.
=== code end ===
However you can't do that with indexed properties (which is the feature
that Ryan meant) as the value returned by the property getter is merely a
copy and not a reference.
For completeness sake: for primitive types (except ShortString) and
implicit pointer types (classes, interfaces, dynamic arrays, string types
except ShortString) this behavior is not relevant.
Regards,
Sven
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20180606/2fdbfa84/attachment.html>
More information about the fpc-pascal
mailing list