Support alias this in module scope?

Rubn where at is.this
Thu May 24 20:19:04 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)

Would there be any use for this other than working around this 
problem with extern(C++) ?

If not then perhaps changing the behavior to be what is desired 
would be better. If we change extern(C++, Namespace) to work only 
for mangling and not as a struct, then existing code would only 
need to create a new module with "Namespace" and statically 
import it to work with existing code. I'd rather the actual 
problem be fixed than having some work around for it. We don't 
even have multiple "alias this" in structs. If a new feature were 
to be added I'd rather it'd be that, which was "approved" but has 
yet to be included.


More information about the Digitalmars-d mailing list