alias Error: need 'this'

Ali Çehreli acehreli at yahoo.com
Sun Mar 19 17:19:07 UTC 2023


On 3/19/23 06:49, bomat wrote:

 > I can live with the `static`
 > solution, I guess.

If you could, you would define it 'static' anyway. :) Because you highly 
likely needed a distinct 'variableWithALongName' member for each 
MyStruct object, that wouldn't work.

 > Shouldn't it be the exact same underlying mechanism?

I don't know the answer. Luckily, what you describe is available in 
another form in the language:

     ref alias2() {
         return myStruct.memberWithALongName;
     }

Ali

Unrelated: I find 'myObject' a more correct name for a variable because 
if 'struct' is the definition of a type, 'myStruct' attempts to convey a 
misleading meaning.



More information about the Digitalmars-d-learn mailing list