I agree with Igor. The readability could be improved and I do not see the problem of hiding built-in php functions (however, I would not recommend it). I would say, if someone hides the normal php built-in function then he or she is doing that on purpose and is aware of the consequences. Thus it is also fine if the same person imports the function, which hides the normal php built-in function, in another namespace.
-----Ursprüngliche Nachricht----- Von: Igor Wiedler [mailto:i...@wiedler.ch] Gesendet: Sonntag, 21. April 2013 23:36 An: internals@lists.php.net Betreff: Re: [PHP-DEV] Importing namespaced functions Let me give you two specific cases where I think importing a function significantly improves the readability of code. A) Tiny libraries I recently released a "library" that really just consists of two functions. Those functions are named compose() and pipeline(), and the library is named "igorw/compose". I didn't want to risk conflicts in the global namespace, so I just put them in the "igorw" namespace. Now users need to do this: $x = igorw\compose('foo', 'bar', 'baz'); It's distracting to have my vendor name in there every time they call the function. They can alias it, but then they just need to come up with a random word that makes no sense. compose\compose(...); c\compose(...); foo\compose(...); B) Domain specific languages I hope I'm not mis-using the term "DSL" here, so just let me explain what I mean. When building some kind of representation of something, it can sometimes be quite nice to have a set of functions representing the elements, and nest those calls. An example of this could be building HTML (you can apply it to building workflows, business rules, graphs, configuration, etc). use html\div, html\p, html\em; $html = div(p('Some', em('Text'))); Having to prefix the namespace in either of these cases leads to a lot of noise. Hopefully that gives you a better idea of where I'm coming from. Regards, Igor -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php