Is there any good reason why C++ namespaces are "closed" in D?

Walter Bright newshound2 at digitalmars.com
Wed Aug 1 09:07:10 UTC 2018


On 7/31/2018 3:34 PM, Laeeth Isharc wrote:
> On Saturday, 28 July 2018 at 01:03:10 UTC, Walter Bright wrote:
>> On 7/27/2018 4:15 PM, Laeeth Isharc wrote:
>>> Can you think of a pragmatic solution to Atila's problem?
>>
>> One way is for the C++ => D translator to gather all the members of a 
>> namespace before trying to emit them. Since D does not impose an order on 
>> declarations (unlike C++) it is not constrained to follow the same order.
> 
> So a new post preprocessor stage that parses the produced D code and regroups to 
> group the declarations in the same namespace together ?  Using DMD as a library 
> or libdparse or something?

I don't know how Atila's translator works.

The htod one that I wrote would read and do the semantic processing on the 
entire file before walking the data structures and emitting the corresponding D 
code, so grouping the namespace declarations would be trivial. In fact, due to 
the nature of semantic processing, they would already be grouped together.


More information about the Digitalmars-d mailing list