[fpc-devel] Feature request/discussion - SetLengthNoInit

Benito van der Zander benito at benibela.de
Wed Sep 16 15:23:33 CEST 2020


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

That is why the new fpc versions always show a "might be 
uninitialized"-warning, when setlength is called without setting the 
array to nil first

Bye,
Benito

On 15.09.2020 11:11, Sven Barth via fpc-devel wrote:
> J. Gareth Moreton via fpc-devel <fpc-devel at lists.freepascal.org 
> <mailto:fpc-devel at lists.freepascal.org>> 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 initialise new elements to zero? If I'm learning one
>     thing, Free
>     Pascal is finding a niche in some scientific applications, and
>     speed can
>     be essential sometimes.
>
>
> 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).
>
> Regards,
> Sven
>
>
>
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20200916/03f5609e/attachment.htm>


More information about the fpc-devel mailing list