If I want to use the name baz
defined in package foo|bar|quz
, I've several choices:
- provide
fbq
as a short name forfoo|bar|quz
and usefbq|baz
- use
foo|bar|quz|baz
- import
baz
fromfoo|bar|quz|baz
and then usebaz
(or an alias given in the import process) - import all public symbols from
foo|bar|quz|baz
and then usebaz
- use
For the languages I know, my perception is that the best practice is to use the first two ways (I'll use one or the other depending on the specific package full name and the number of symbols I need from it). I'd use the third only in a language which doesn't provide the first and hunt for supporting tools to write the import statements. And in my opinion the fourth should be reserved to package designed with than import in mind, for instance if all exported symbols start with a prefix or contains the name of the package.
My questions:
- what is in your opinion the best practice for your favorite languages?
- what would you suggest in a new language?
- what would you suggest in an old language adding such a feature?