Disappointing inflexibility of argument passing with "alias this"

Adam D. Ruppe via Digitalmars-d digitalmars-d at puremagic.com
Mon Feb 22 09:29:40 PST 2016


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.


More information about the Digitalmars-d mailing list