Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-18 Thread Ryan Joseph via fpc-devel
> On Sep 17, 2020, at 7:23 PM, Ryan Joseph wrote: > > Certainly. I think it depends on what the solution is. It's a known short > coming of the [] property and if the solution is as easy as allowing a var > param variant then maybe it's feasible. I'm remembering now I believe we did discuss

Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-17 Thread Ryan Joseph via fpc-devel
> On Sep 17, 2020, at 11:33 AM, J. Gareth Moreton via fpc-devel > wrote: > > I think the difficulty with getting things like this approved is that it > crosses into the realm of defining the language itself. I can't say I speak > on behalf of Florian or Jonas, but I sense they want to avoid

Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-16 Thread Ozz Nixon via fpc-devel
Then, I would suggest it gets bolted into strutils, or sysutils. There are many good reasons to optimize Setlength(), especially for script authors :-) Currently, I am working (learning) Alpha Controls (alphaskins), and trying to find a fit into FCL/LCL, or Graeme's GUI. And if I tweak too much, t

Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-16 Thread J. Gareth Moreton via fpc-devel
Ah yes, that works, thanks. I feel a bit silly because I haven't explored these useful features as much as I should, possibly because assembly language isn't object oriented! I think the difficulty with getting things like this approved is that it crosses into the realm of defining the langua

Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-16 Thread Ryan Joseph via fpc-devel
Here's an example of the main problem that keeps us from using custom types to replace dynamic arrays. We basically a need [] property modifier that treats records the same way the dynamic array syntax does. GetValue could be a procedure and use a var parameter and maybe even that would be enoug

Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-16 Thread Ryan Joseph via fpc-devel
> On Sep 17, 2020, at 9:59 AM, J. Gareth Moreton via fpc-devel > wrote: > > type generic TMyArray = record > Data: ^T; > Length: PtrUInt; > end; > > The compiler will complain about T being an unresolved forward declaration. > Outside of specifying a second parameter for the pointer typ

Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-16 Thread J. Gareth Moreton via fpc-devel
I hope they do allow you to fix it, because those features look useful, especially with custom-made dynamic arrays (through a generic record).  I've got to try playing with them now to see if I can make something that Chris Rorden would use! Though not really related, it's not easy to specify

Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-16 Thread Ryan Joseph via fpc-devel
> On Sep 16, 2020, at 9:10 PM, J. Gareth Moreton via fpc-devel > wrote: > > I figure I could design a dynamic array class, but it will very likely be > incompatible with SetLength no matter what I try to do, and unless I'm > mistaken, it won't have the benefit of automatically gaining an imp

Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-16 Thread Sven Barth via fpc-devel
Benito van der Zander via fpc-devel schrieb am Mi., 16. Sep. 2020, 15:30: > > Hi, > > > I'm against adding support for this. Dynamic arrays have guaranteed > behavior. If users find that this behavior is not appropriate for their use > case then they should not use them (or as you already suggest

Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-16 Thread Sven Barth via fpc-devel
J. Gareth Moreton via fpc-devel schrieb am Mi., 16. Sep. 2020, 16:10: > I did wonder if it was possible to use an object of some kind or, I dare > say, some evil low-level manipulation of its internal structure wrapped > into a convenient function that, say, calls ReallocMem on the internal > poi

Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-16 Thread Michael Van Canneyt via fpc-devel
On Wed, 16 Sep 2020, Benito van der Zander via fpc-devel wrote: Hi, I'm against adding support for this. Dynamic arrays have guaranteed behavior. If users find that this behavior is not appropriate for their use case then they should not use them (or as you already suggested, preallocat

Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-16 Thread J. Gareth Moreton via fpc-devel
I did wonder if it was possible to use an object of some kind or, I dare say, some evil low-level manipulation of its internal structure wrapped into a convenient function that, say, calls ReallocMem on the internal pointer and sets the length field as normal.  The trouble is, that will be inhe

Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-16 Thread Benito van der Zander via fpc-devel
Hi, I'm against adding support for this. Dynamic arrays have guaranteed behavior. If users find that this behavior is not appropriate for their use case then they should not use them (or as you already suggested, preallocate them). well, setlength does not always initialize the array Tha

Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-15 Thread RORDEN, CHRIS via fpc-devel
I think dynamic arrays are really elegant features of Pascal and a strong benefit versus C. However, when working with large projects one encounters situations where one wants more. control. I would advocate allowing developers to optionally use SetLengthNoInit and also allowing user to specify

Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-15 Thread RORDEN, CHRIS via fpc-devel
The dynamic arrays in Lazarus have so many terrific properties. Giving power users the ability to not initialize them would give clear performance benefits. This is useful in real world sitautions where one has long term arrays, but also can use transient arrays of the same type. Another feature

Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-15 Thread Ryan Joseph via fpc-devel
> On Sep 15, 2020, at 10:34 PM, J. Gareth Moreton via fpc-devel > wrote: > > I'm willing to settle with SetLength(array, len, ... len, NoInit: Boolean = > False), but of course it depends on the overall support for it, which isn't > looking too promising currently! > > I'd rather put the

Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-15 Thread J. Gareth Moreton via fpc-devel
You all make good points.  It's why I didn't suggest changing SetLength because of the well-defined and safe behaviour, and yes, the System unit is already crowded with intrinsics, and will become even more crowded once the naming format of the assembly intrinsics are finalised.  The optional p

Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-15 Thread Sven Barth via fpc-devel
J. Gareth Moreton via fpc-devel schrieb am Mo., 14. Sep. 2020, 19:00: > With all this in mind, would there be support for an intrinsic such as > "SetLengthNoInit" or "SetLengthNoClear" or some similar name that has > all the benefits of SetLength (especially the reference counting) but > doesn't

Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-14 Thread Michael Van Canneyt via fpc-devel
On Mon, 14 Sep 2020, J. Gareth Moreton via fpc-devel wrote: On 14/09/2020 19:41, Michael Van Canneyt via fpc-devel wrote: Better add an additional (optional) parameter SkipInit : Boolean = False; Michael. That won't work because constructs such as "var Data: array of array of Byte; SetLen

Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-14 Thread J. Gareth Moreton via fpc-devel
On 14/09/2020 19:41, Michael Van Canneyt via fpc-devel wrote: Better add an additional (optional) parameter SkipInit : Boolean = False; Michael. I was probably a bit too critical in my last e-mail.  I'm sure it's possible given SetLength is an intrinsic rather than a real subroutine.  Is it

Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-14 Thread J. Gareth Moreton via fpc-devel
On 14/09/2020 19:41, Michael Van Canneyt via fpc-devel wrote: Better add an additional (optional) parameter SkipInit : Boolean = False; Michael. That won't work because constructs such as "var Data: array of array of Byte; SetLength(Data, 25, 25);" are allowed.  Eevn if it's technically an i

Re: [fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-14 Thread Michael Van Canneyt via fpc-devel
On Mon, 14 Sep 2020, J. Gareth Moreton via fpc-devel wrote: Hi everyone, This is something that came up in a discussion with a client. One thing he noticed when using SetLength with dynamic arrays is that it can cause a CPU bottleneck because it initialises the entire block to zero, which

[fpc-devel] Feature request/discussion - SetLengthNoInit

2020-09-14 Thread J. Gareth Moreton via fpc-devel
Hi everyone, This is something that came up in a discussion with a client. One thing he noticed when using SetLength with dynamic arrays is that it can cause a CPU bottleneck because it initialises the entire block to zero, which is often undesirable if the array is going to be overwritten wit