10
$\begingroup$

Different languages have different naming conventions for their modules. For example, Java-family languages usually use full reverse-domain-name names for packages (ie com.example.examplemodule). Python, however, lets you name your modules whatever you want. What are the pros and cons of these methods, and are there any other ones?

$\endgroup$
7

1 Answer 1

3
$\begingroup$

The most common schemes seen are foo.bar.baz and foo::bar::baz (I don't think I need to mention the PHP scheme).

  • Hierarchal names like this makes it easy to organize libraries in sub modules, e.g. my_lib.io.foo my_lib.net.bar.

  • It allows recursive inclusion of sub modules, e.g "import my_lib.*".

  • Code completion etc can be made more relevant, e.g. my_lib.<code complete to find sub modules> or my_lib.io.<code complete finds io functions>

  • Fairly unexplored is the idea of path shortening, where the compiler could choose to require only a subset of a namespace path, so for example using net.bar to refer to my_lib.net.bar if it is unambiguous (C3 uses this)

  • A separator also makes the name a bit less ambiguous. Compare net.address.File and net_address.File.

$\endgroup$
1
  • $\begingroup$ I think the question's more about the names of packages/libraries as a whole rather than modules/components of them $\endgroup$ Jul 1, 2023 at 3:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .