Array literals are weird.

Adam D. Ruppe destructionator at gmail.com
Sat May 1 12:35:00 UTC 2021


On Saturday, 1 May 2021 at 12:27:30 UTC, Blatnik wrote:
> Yea I can see how that would be a problem if array literals 
> were static arrays by default. But even right now the compiler 
> is able to catch this mistake pretty easily:

Yeah, it works now but that's again relatively new. It wasn't 
there when this stuff was designed.

It'd probably break a lot of code if this were to change now.

> auto y = [1, 2, 3].dup; // I explicitly asked for it, please 
> allocate!

yeah that'd probably be ok.


More information about the Digitalmars-d mailing list