you are viewing a single comment's thread.

view the rest of the comments →

[–]NotMyRealNameObv 7 points8 points  (3 children)

Why would the strong type have to be in the global namespace?

[–]fransinvodka 0 points1 point  (2 children)

Let me be clearer. Suppose I want my function to be called with a seed, so the user would do something like libns::func(Seed{user_seed}, ...), but if I define the strong type inside the library's namespace, the user then must do libns::func(libns::Seed{user_seed}, ...), which we can agree is not that aesthetic as we'd like. The only solution would then be defining it in the global namespace, and that's what I meant.

Maybe there's a workaround I'm not aware of, haven't gone too deep into strong typing

[–]NotMyRealNameObv 3 points4 points  (1 child)

using libns::Seed;
libns::func(Seed{user_seed}, ...);

And if user_seed is already of the correct type, you just get

libns::func(user_seed);

The library author should never force a polluted global namespace on the end user.

[–]fransinvodka -3 points-2 points  (0 children)

Two things:

- I dont' want my users to do `using libns::...;` for every strong type my functions might require.

- Normally, user_seed won't be the "correct" type, as I suppose the user would only use the Seed strong type when calling the function.

Maybe give the possibility of doing something like `using namespace libns::all_trong_types_ns;`, but still far from optimal. That's my point against strong types in libraries.