On Wednesday, 2 October 2019 at 17:54:20 UTC, H. S. Teoh wrote:
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

I was trying to avoid such things since X is quite long in name. Not a huge deal... and I do not like the syntax because it looks like a constructor call.

Reply via email to