Why is "array operation without destination memory not allowed"?

Lily yulex.42 at gmail.com
Sat Jan 6 23:42:42 UTC 2018


On Saturday, 6 January 2018 at 23:17:53 UTC, Ali Çehreli wrote:
> So, apparently a[] * 2 is not an expression in D.

> The reason must be for performance. If a[]*2 were an 
> expression, the runtime would have to allocate memory and put 
> the results there. Assigning that memory then to b[] would 
> require an additional copy. Current rule puts the burden on the 
> programmer to find the memory. No need to allocate if there's 
> memory already.

That makes sense, thanks!


More information about the Digitalmars-d-learn mailing list