On Monday, 23 January 2023 at 00:27:29 UTC, Adam D Ruppe wrote:
On Monday, 23 January 2023 at 00:21:12 UTC, thebluepandabear wrote:
there's nothing in the language currently that would 'force' the user

Why do you hate freedom?

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?

```C++
Keyboard::Key.A
```

```C++
Key.A
```

The first one does, because looking at the second one, the person who will read the code might be confused what 'Key' means, is it a car key, a set of keys for unlocking something, etc?

Now, the user doesn't have to use the library if they don't want to. There will be plenty of libraries out there that don't have namespaces.

I haven't been programming for a long time, but most of the other languages I used had such a namespace feature. Kotlin has something called an `object` which is essentially a namespace and it is great. The benefits of adding a namespace-like feature outweigh its costs, imo.

Reply via email to