Re: [fpc-devel] Aligned dynamic arrays

2019-03-29 Thread Anthony Walter
Inside the type I have: TAlignedArray = record public type TReference = ^T; TValue = T; ... procedure Push(const Item: TValue); function Pop: TValue; property Length: Integer read FLength write SetLength; property Reference[Index: Integer]: TReference read G

Re: [fpc-devel] Aligned dynamic arrays

2019-03-29 Thread Ryan Joseph
> On Mar 29, 2019, at 9:15 PM, Anthony Walter wrote: > > Ryan, actually ... > > A.Length := 1; > A[0].X := 100; > > ... does work in my implementation. Really, how? [] property uses a getter which copies the array right? I’mm not aware of how to do this in Pascal without pointers. Regards,

Re: [fpc-devel] Aligned dynamic arrays

2019-03-29 Thread Anthony Walter
Ryan, actually ... A.Length := 1; A[0].X := 100; ... does work in my implementation. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Re: [fpc-devel] Aligned dynamic arrays

2019-03-29 Thread Ryan Joseph
> On Mar 29, 2019, at 5:25 PM, Sven Barth via fpc-devel > wrote: > > Ignoring something is not an answer. At least there'd need to be a runtime > error. > > Thinking about it maybe it would be better to follow Anthony's idea with the > record and not try to adjust/extend a language mechanis

Re: [fpc-devel] Aligned dynamic arrays

2019-03-29 Thread Marco van de Voort
Op 3/28/2019 om 11:40 PM schreef Anthony Walter: Here is a brief follow up. I am working on other projects at the moment, but I am confident this a simple solution. Please tell me if this somehow will not fit you needs. My needs are simple: - auto clean like dynamic arrays. - preferably tran

Re: [fpc-devel] Aligned dynamic arrays

2019-03-29 Thread Sven Barth via fpc-devel
Am 29.03.2019 um 17:53 schrieb Ryan Joseph: First minor snag, fpc_dynarray_insert, fpc_dynarray_concat can allocate new arrays like SetLength can. Do we need to make aligned variants for these also? Using array + operators there is no possibility to set alignment. var a, b: array of integer

Re: [fpc-devel] Aligned dynamic arrays / Maybe implement in mem-mgr?

2019-03-29 Thread Ryan Joseph
> On Mar 29, 2019, at 1:21 PM, Martin Frb wrote: > > Question: Should the alignment be "user data" or "type info". > Does it need to be determined at runtime, and set to different values (for > the same type/variable) at runtime? I’m just doing what Sven said I could do, which is store the in

Re: [fpc-devel] Aligned dynamic arrays / Maybe implement in mem-mgr?

2019-03-29 Thread Martin Frb
On 29/03/2019 17:53, Ryan Joseph wrote: First minor snag, fpc_dynarray_insert, fpc_dynarray_concat can allocate new arrays like SetLength can. Do we need to make aligned variants for these also? Using array + operators there is no possibility to set alignment. 1) ignore the problem 2) make ext

Re: [fpc-devel] Aligned dynamic arrays

2019-03-29 Thread Ryan Joseph
First minor snag, fpc_dynarray_insert, fpc_dynarray_concat can allocate new arrays like SetLength can. Do we need to make aligned variants for these also? Using array + operators there is no possibility to set alignment. var a, b: array of integer; begin a += [1]; // no way to set alignment

Re: [fpc-devel] Aligned dynamic arrays

2019-03-29 Thread Anthony Walter
Gareth, There is a bounty for this? I wonder if my solution is acceptable. Also, my solution, or any for that matter, could be enhanced to make the alignment size configurable per each array aligned array. That is, memory alignment starting position and page size could be defined by each array. T

Re: [fpc-devel] Aligned dynamic arrays

2019-03-29 Thread J. Gareth Moreton
I wonder if there's any incentive to have such a feature in-built in the compiler.  The bounty on #34031 has probably expired by now.  If not, then your unit would be a great addition. Page-aligned memory is probably something that warrants further discussion with the core team. Gareth aka. Kit