Support alias this in module scope?

Manu turkeyman at gmail.com
Wed May 23 04:23:33 UTC 2018


On 22 May 2018 at 20:53, Stefan Koch via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> 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.

I know, but it shouldn't be... they should just be normal extern(C++)
functions with an extra detail in the attribute for mangling.


More information about the Digitalmars-d mailing list