On Wed, Oct 02, 2019 at 05:37:57PM +0000, Brett via Digitalmars-d-learn wrote:
> struct X { int a; }
>
> X[1] x;
>
> x[0] = {3};
>
> or
>
> x[0] = {a:3};
>
> fails;
This works:
x[0] = X(123);
> Should the syntax not extend to the case of array assignment?
Arguably it should. But it's mainly cosmetic, since the X(123) syntax
works just fine. (It *is* an incongruity in D's syntax, though. It's not
a big deal once you learn it, but it's a bit counterintuitive the first
time you need to use it.)
> This avoids a double copy.
[...]
Which any modern optimizer would optimize away.
T
--
It is of the new things that men tire --- of fashions and proposals and
improvements and change. It is the old things that startle and intoxicate. It
is the old things that are young. -- G.K. Chesterton