<div dir="ltr"><div dir="ltr">On Mon, Jul 8, 2019 at 2:22 PM Ryan Joseph <<a href="mailto:genericptr@gmail.com">genericptr@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
and it will actually write to the actual record in the array and not a returned copy. However due to how the properties are currently structured this means we can’t use the setter without passing pointers<br></blockquote><div><br></div><div>Ah, I see what you mean. Note you can at least work around this for now with operator overloading:</div><div><br></div>program Example;<br><br>{$mode Delphi}{$H+}<br><br>uses SysUtils;<br><br>type<br> PVec3F = ^TVec3F;<br><br> TVec3F = record<br> X, Y, Z: Single;<br> class operator Implicit(constref From: TVec3F): PVec3F; inline;<br> end;<br><br> class operator TVec3F.Implicit(constref From: TVec3F): PVec3F;<br> begin<br> Result := @From;<br> end;<br><br>type<br> TList<T> = record<br> public type<br> PT = ^T;<br> strict private<br> FData: array of T;<br> private<br> function GetItem(const I: PtrUInt): PT; inline;<br> procedure SetItem(const I: PtrUInt; const Val: PT); inline;<br> function GetLength: PtrInt; inline;<br> procedure SetLength(const I: PtrInt); inline;<br> public<br> property Items[const I: PtrUInt]: PT read GetItem write SetItem; default;<br> property Length: PtrInt read GetLength write SetLength;<br> end;<br><br> function TList<T>.GetItem(const I: PtrUInt): PT;<br> begin<br> if I < System.Length(FData) then<br> Result := @FData[I]<br> else<br> Result := nil;<br> end;<br><br> procedure TList<T>.SetItem(const I: PtrUInt; const Val: PT);<br> begin<br> if I < System.Length(FData) then<br> FData[I] := Val^;<br> end;<br><br> function TList<T>.GetLength: PtrInt;<br> begin<br> Result := System.Length(FData);<br> end;<br><br> procedure TList<T>.SetLength(const I: PtrInt);<br> begin<br> System.SetLength(FData, I);<br> end;<br><br>var<br> I: PtrUInt;<br> Vec: TVec3F = (<br> X: 0.0;<br> Y: 0.0;<br> Z: 0.0;<br> );<br> VecList: TList<TVec3F>;<br><br>begin<br> VecList.Length := 1;<br> VecList[0] := Vec;<br> with VecList[0]^ do begin<br> X := 2.0;<br> Y := 4.0;<br> Z := 6.0;<br> end;<br> // Access it again, separately...<br> with VecList[0]^ do<br> WriteLn(Format('[%f %f %f]', [X, Y, Z]));<br><div>end. </div></div></div>