3 ms·
The way I see it is that you alias the import mail as mailer. You hope there are no other libraries called mail in your import path. PHP fixes that by requiring
by ainiriand 5y ago
The way I see it is that you alias the import mail as mailer. You hope there are no other libraries called mail in your import path. PHP fixes that by requiring all libraries called mail to be dependent on their own namespace so that there will be no collisions.
I think that neither do make assumptions on how the code is called when used, only one is preventing name collisions.
- deleted 5y ago[deleted]
- TekMol 5y agoYou hope there are no other libraries called mail in your import path. Let's take Python for example. With Python, I am in control of the import path. I can put those two mail modules in: stuff/mail tools/mail And then use them like this: from stuff import mail as mail1 from tools import mail as mail2 I don't have to hope for anything.
- sandruso 5y agoIsn’t this same thing? Your dir in python structure is dictating the namespace isn’t it?
- TekMol 5y agoThe dir structure is defined by me. Namespaces are defined by the 3rd party developer.
- ainiriand 5y agoThat is not exactly true, you can tweak composer to put dependencies anywhere you want them. What I feel is that there is a minor inconvenience, as many other languages have, and you try to build a case to bring down a whole ecosystem.
- leegraham 5y agoThat example would become `use Stuff\Mail as Mail1` and `use Tools\Mail as Mail2` in PHP. What's the difference?
- TekMol 5y agoThe difference is that in PHP, the developers of "Stuff\Mail" and "Tools\Mail" would have to define "Stuff" and "Tools" as the namespace for their code. In Python, they don't have to do anything. The project that uses the code decides.