alias Error: need 'this'

Basile B. b2.temp at gmx.com
Sun Mar 19 16:49:07 UTC 2023


On Sunday, 19 March 2023 at 13:49:36 UTC, bomat wrote:
> Thanks for the suggested workaround, I can live with the 
> `static` solution, I guess.
>
> I still don't understand why it's necessary, though.
> Since a `struct` is a value type and, as I understand it, stack 
> allocated, what difference does it make to the compiler whether 
> I alias `variableWithALongName` or 
> `myStruct.memberWithALongName`?
> Shouldn't it be the exact same underlying mechanism?
>
> Thanks and regards
> bomat

D aliases are for symbols, but what you try to alias is an 
expression.

You might feel that what  you request may work, but that's only a 
very particular case. Generally expressions cannot be aliased 
because without context they become polymorphic (or erather 
polysemous).


More information about the Digitalmars-d-learn mailing list