Non-ugly ways to implement a 'static' class or namespace?
thebluepandabear
therealbluepandabear at protonmail.com
Mon Jan 23 00:21:12 UTC 2023
> That way of naming a global function is essentially a poor
> man's^W^Wexcuse me, I mean, C's way of working around the lack
> of a proper namespacing / module system. In D, we do have a
> proper module system, so you could just call the function
> `drawLine` and put it in a file named Algo.d, then you can just
> use D's symbol resolution rules to disambiguate between
> Algo.drawLine and PersonalSpace.drawLine, for example. :-P
>
>
> T
Again, stuffing it into a module is not the same thing as a
namespace. The user can just bypass this by writing `drawLine`,
there's nothing in the language currently that would 'force' the
user to write in a namespace-like/static-class-like fashion, and
that's the biggest problem.
More information about the Digitalmars-d-learn
mailing list