Re: alias Error: need 'this'

2023-03-19 Thread Ali Çehreli via Digitalmars-d-learn
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

Re: alias Error: need 'this'

2023-03-19 Thread Basile B. via Digitalmars-d-learn
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

Re: alias Error: need 'this'

2023-03-19 Thread bomat via Digitalmars-d-learn
On Sunday, 19 March 2023 at 12:29:19 UTC, Salih Dincer wrote: It is possible to achieve the convenience you want to achieve in 2 ways. One of them is to use a static member but if not, to use an alias inside the container. Thanks for the suggested workaround, I can live with the `static`

Re: alias Error: need 'this'

2023-03-19 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 19 March 2023 at 11:52:50 UTC, bomat wrote: It works fine with the `int` variable, but with the struct member I get a compilation error: ``` Error: need `this` for `memberWithALongName` of type `int` ``` What is that supposed to mean? It is possible to achieve the convenience you