ariovistus / pyd

Interoperability between Python and D
MIT License
159 stars 32 forks source link

rename util to `module pyd.util;` #140

Closed mw66 closed 4 years ago

mw66 commented 4 years ago

https://forum.dlang.org/post/mailman.6416.1603928138.31109.digitalmars-d-learn@puremagic.com

I run into a similar issue today:

-- I try to use a library pyd, and -- my local project has a file called "source/util.d"

the dub build error out:

/.dub/packages/pyd-0.13.1/pyd/infrastructure/util/typelist.d(1,1): Error: package name 'util' conflicts with usage as a module name in file source/util.d

I wonder what's the best way to resolve this conflict, i.e my local file name with 3rd party library dir name.

Don't write any module with a single name unless you are guaranteed to never import it.

pyd should have called it like module pyd.util;

Then you call yours like module mw.util;

This makes such conflicts a lot less likely.

IMO, 3rd party libraries should always be in their own package namespace. Leave the top-level for user code! Why should a local module 'util' conflict with any dependency? It should be the library author's job to make sure his code doesn't conflict with the user's!