Disappointing inflexibility of argument passing with "alias this"
H. S. Teoh via Digitalmars-d
digitalmars-d at puremagic.com
Mon Feb 22 10:11:58 PST 2016
On Mon, Feb 22, 2016 at 06:07:26PM +0000, rsw0x via Digitalmars-d wrote:
> 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
AFAICT, implicit ctors are not supported by design.
T
--
Ruby is essentially Perl minus Wall.
More information about the Digitalmars-d
mailing list