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

Kagamin spam at here.lot
Fri Feb 10 14:17:25 UTC 2023


On Monday, 23 January 2023 at 00:36:36 UTC, thebluepandabear 
wrote:
> It's not a freedom issue, it's a library-design issue. Some 
> libraries want to incorporate a namespace-like design to force 
> the user to be more 'explicit' with what they want.
>
> SFML has a `Keyboard` namespace which has a `Key` enum.
>
> The user is 'forced' (although I am not sure if this is the 
> case since it's C++) to use the `Keyboard.` declaration before 
> using the `Key` enum. Looking at code block 1 and 2, which 
> makes more sense?

Pretty sure you can strip namespaces in any language that has 
namespaces, C# routinely does it and refers to all types with 
their nonqualified names. It even has Keys enum: 
https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.keys which is referred to as Keys after stripping the System.Windows.Forms namespace.


More information about the Digitalmars-d-learn mailing list