No bounds checking for dynamic arrays at compile time?

Marco Nembrini marco.nembrini.co at gmail.com
Wed Dec 12 21:09:32 PST 2012


On Thursday, 13 December 2012 at 04:54:33 UTC, Walter Bright 
wrote:
> On 12/12/2012 8:11 PM, Pacoup wrote:
>> Static arrays throw out of bounds errors on compilation when 
>> there's a mismatch,
>> but why not dynamic arrays?
>
> Because the length of dynamic arrays is unknown at compile time.

That's true in general, but in this particular case you could see 
at compile time that the array is never resized and give a 
warning. Obvously as soon as there is one resizing somewhere with 
some run-time value you cannot do it anymore.

I wonder if that would be useful?


More information about the Digitalmars-d mailing list