Non-ugly ways to implement a 'static' class or namespace?

Ali Çehreli acehreli at
Sun Feb 5 23:50:35 UTC 2023

On 2/5/23 02:57, thebluepandabear wrote:

 > When dealing with contexts, or for when you want a clear context in your
 > codebase, namespaces can be a life saver

Can you give an example of a D problem that namespaces could solve? I 
have been with D for 14 years and haven't missed namespaces from C++ ever.

The reason I ask is, mentioning lack of features of other programming 
languages is not the right way to go. We have to understand what problem 
they were trying to solve with that feature and then see how D already 
tackels it.

In this case, it is namespacing and D solves it with the following 
feature and perhaps others that I can't think of:

- modules
- structs
- classes
- templates

I don't consider myself a maintainer of D but I don't agree that yet 
another feature for namespacing is needed. I feel that it would bring 

I don't think it is practical to bring all features of all languages 
into D or any other language.

 > we've seen it used in the D
 > library, so there's no excuse for why this shouldn't be added, in my
 > opinion.

If I'm not mistaken you've counted five such instances. Were they really 
necessary? Could they be coded in a different way? What is the cost of 
missing namespaces? I think you are the first person raising this issue.

You must have a strong case for this feature; so, I recommend you write 
a DIP for it. It is likely that the mere act of doing that will expose 
hidden costs and usage problems.


More information about the Digitalmars-d-learn mailing list