why static array can be reassigned with new allocation?

Per Nordlöw per.nordlow at gmail.com
Sun Oct 16 20:26:58 UTC 2022


On Saturday, 15 October 2022 at 10:31:16 UTC, matheus wrote:
> On Friday, 14 October 2022 at 20:19:20 UTC, Ali Çehreli wrote:
>> ...
>> The compiler does not perform detailed analysis of all code. 
>> Since that 5 could be a runtime expression, the compiler does 
>> not check it at compile time.
>> ...
>
> Yes but in this case it's known during the compiling time 
> (Literal 5), couldn't this be checked a prevented?
>
> Matheus.

It could. And it's not hard to add it but I'm not sure it would 
be accepted.

We should instead deprecate

’’’d
new T[n]
’’’

in favor of

’’’d
new T[](n)
’’’

.


More information about the Digitalmars-d mailing list