logoalt Hacker News

HarHarVeryFunnylast Saturday at 7:15 PM1 replyview on HN

Namespaces to me are more about naming conflict resolution and code readability, and I think of them more as prefixes to namespace member names, as opposed to those member names being part of a hierarchy.

It also helps code readability to know that a::b is referring to a namespace, without having to go lookup the definition of "a", while a.b is a variable access.


Replies

zephenlast Saturday at 7:38 PM

> Namespaces to me are more about naming conflict resolution and code readability, and I think of them more as prefixes to namespace member names, as opposed to those member names being part of a hierarchy.

That's a perspective. Are we talking about the 'bar' that comes from 'foo' or are we talking about the 'bar' that comes from 'baz'?

But another perspective is that 'foo' is important and provides several facilities that are intimately related to foo, so 'bar' is simply one of the features of foo.

> It also helps code readability to know that a::b is referring to a namespace

For you, perhaps. As someone who reads a lot of Python, I don't personally find this argument persuasive.

show 1 reply