This doesn't make sense regarding alias this a static function

Steven Schveighoffer schveiguy at yahoo.com
Sun May 16 16:38:08 UTC 2021


On Sunday, 16 May 2021 at 15:45:48 UTC, 12345swordy wrote:
> ```struct TIntStatic
> {
>     static int mX;
>
>     static @property int x() { return mX; }
>     static @property void x(int v) { mX = v; }
>
>     alias x this;
> }
> ```
>
> It doesn't like the following code
> ```
>
> alias t = TIntStatic;
> t(5);
> ```
> Yet is perfectly fine with this
> ```
> alias t = TIntStatic;
> t = 5;
> ```
> What is with the inconsistency? If you allow t = 5 then surely 
> you must allow t(5) as part of alias this a function.

That’s considered a constructor. And there’s no member to accept 
the 5.

-Steve




More information about the Digitalmars-d mailing list