Is `alias this` a mistake?

bachmeier no at spam.net
Wed Aug 4 14:32:17 UTC 2021


On Tuesday, 3 August 2021 at 20:19:56 UTC, Alexandru Ermicioi 
wrote:
> On Tuesday, 3 August 2021 at 17:18:48 UTC, bachmeier wrote:
>> On Tuesday, 3 August 2021 at 15:52:07 UTC, NonNull wrote:
>>> Here, further down, I just saw Walter indicate his opinion 
>>> that `alias this` is a mistake. Any thoughts?
>>>
>>> https://news.ycombinator.com/item?id=28029184
>>
>> The only argument I've heard against alias this is that it can 
>> be misused. That's kind of a joke argument in a language that 
>> has pointers.
>
> Fyi, 'alias this' nicely fits for doing auto unboxing of a 
> wrapper type into wrapped type, similar to how java does 
> unboxing of primitives, not sure that it will be possible with 
> mixin templates.

It's difficult to beat the simplicity of alias this. Even if 
something cam be done with mixin templates, that's a lot of 
overhead vs `alias x this;`. I can't say I use mixin templates 
very often, but am skeptical that there's no way to misuse them.


More information about the Digitalmars-d mailing list