Support alias this in module scope?

Stefan Koch uplink.coder at googlemail.com
Wed May 23 03:53:59 UTC 2018


On Wednesday, 23 May 2018 at 03:44:36 UTC, Manu wrote:
> Okay, I'm still really angry about the stupid stupid decision 
> to make C++ namespaces into scopes rather than just a detail 
> used for mangling, with absolutely no consultation of the 
> community, in particular the target audience, who are 
> unanimously annoyed as far as I can tell...
>
> I'm unsatisfied by the work-arounds to make the situation 
> not-suck, but I think I have an idea that would pacify me...
>
> If we can use `alias this` to mirror an entire C++ namespace 
> into the location we want (ie, the scope immediately outside 
> the C++ namespace!!), then one sanitary line would make the 
> problem quite more tolerable:
>
> extern(C++, FuckOff)
> {
>   void bah();
>   void humbug();
> }
> alias this FuckOff;  // <-- symbols are now aliased where they 
> should
> have been all along
>
>
>
> (count the seconds until the reply that says to use reflection 
> to scan the scope, and use a mixin to... blah blah)

After thinking about it for a few minutes I do believe this is a 
reasonable approach.
I am in favor of module-level alias this.

The reason name-spaces create a scope is because they are 
essentially implemented via structs.


More information about the Digitalmars-d mailing list