Member-assignment for std.container.Array!Struct
monarch_dodra
monarchdodra at gmail.com
Fri Jan 10 00:53:50 PST 2014
On Friday, 10 January 2014 at 08:27:42 UTC, Andrei Alexandrescu
wrote:
> It's an outrage, and this particular combination of
> (mis)features has never got to my attention until now.
>
> I've submitted
> https://d.puremagic.com/issues/show_bug.cgi?id=11889 on your
> behalf. I've also sent out the fix
> https://github.com/D-Programming-Language/phobos/pull/1845 for
> review. (It's simple, but perhaps I'm missing some subtler
> issues.)
>
> Apologies for this!
>
>
> Andrei
Array returns a value by design. I don't think it's array that's
wrong here, it's being able to assign to members of an rvalue
(IMO).
Off the top of my head, a possible language enhancement would be
to allow member functions to be marked as "ref", in which case,
they only work on lvalue (as applying the function on a temp
would make no sense).
eg:
struct S
{
void doit();
void opAssign(int) ref;
}
void main()
{
S().doit(); //OK, rvalue call
S() = 5; //Nope, opAssign requires an lvalue.
}
More information about the Digitalmars-d
mailing list