Disappointing inflexibility of argument passing with "alias this"
rsw0x via Digitalmars-d
digitalmars-d at puremagic.com
Mon Feb 22 10:07:26 PST 2016
On Monday, 22 February 2016 at 17:29:40 UTC, Adam D. Ruppe wrote:
> On Monday, 22 February 2016 at 17:22:51 UTC, Carl Sturtivant
> wrote:
>> struct Test { int i; alias i this; }
>> [...]
>> The assignment is fine, but the call is rejected by dmd.
>
>
> Test t = 1;
>
> is rejected too because alias this is not a constructor and a
> function call would be construction.
>
> I do think it would be very nice to have explicitly implicit
> constructors which would cover both these cases (then we can do
> user-defined types that accept the null literal in function
> calls too just like built in arrays!), but I don't think it has
> anything to do with alias this.
explicitly-implicit constructors are badly needed, I could write
an essay on this
More information about the Digitalmars-d
mailing list