<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Ryan Joseph <<a href="mailto:ryan@thealchemistguild.com" target="_blank" rel="noreferrer">ryan@thealchemistguild.com</a>> schrieb am Do., 28. März 2019, 03:01:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Here’s the basic structure:<br>
<br>
[header][padding][offset][head]<br>
<br>
[head] being the start of the elements (the pointer to the first element of the array) and aligned to the requested amount. Keep in mind the head is the pointer which is passed around so we need to subtract back from that in order to access the header, which contains the array high value and the refcount.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">The order should be </div><div dir="auto"><br></div><div dir="auto">[padding] [header] [data]</div><div dir="auto"><br></div><div dir="auto">with the offset being part of the header. This way you reduce the changes needed to only those that allocate/free an array.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Look at the dynarr.inc in the /rtl directory to see what I’m talking about. Pretty hard to explain without seeing how Sven did things. :)<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Most of that isn't my code. I only added Insert, Delete and Concat. </div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
> <br>
> The comment:<br>
> As for extending the array header, maybe introduce a new data type "aligned array".<br>
> So normal arrays do not have that field in there header.<br>
<br>
The plan was to make a “SetLengthAligned” or add an extra parameter to “SetLength”, i.e, SetLength(arr,100,true). I have no preference, what ever the compiler team wants.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Extending SetLength is not a good idea as that can take multiple lengths for multi dimensional arrays. </div><div dir="auto"><br></div><div dir="auto">Also I don't think that a simple "do alignment or not" will be sufficient. What kind of alignment do you pick? What if the user needs more alignment? So it would probably be best to add a new SetLengthAligned of which the second argument is the alignment followed by the lengths. </div><div dir="auto"><br></div><div dir="auto">In dynarr.inc you then add a new setlength variant that takes an additional alignment parameter while the old one without alignment calls the new one with alignment 1.</div><div dir="auto"><br></div><div dir="auto">Note: the compiler can call the new one for both variants, but the old one is required for bootstrapping, so you could surround that with {$if not defined(ver3_0) and not defined(ver3_2)}.</div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>