Re: Importing namespaced functions
| From: | Christoph Rosse | Date: | Fri, 19 Apr 2013 13:48:05 +0000 |
| Subject: | Re: Importing namespaced functions | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-67099@lists.php.net to get a copy of this message | ||
On 19.04.2013 08:19, Stas Malyshev wrote:
Hi!And strlen wouldn't be "suddenly" overridden because you would have to explicitly import it, so this argument could be used for namespaces too because if I "use some\ns\DateTime" DateTime is "suddenly" overridden. -- Christoph Rosse Softwaredevelopment | Operations ________________________________________ 2bePUBLISHED Internet Services Austria GmbH Brünner Straße 85/2, 1210 Wien Tel.: 0043.1.9971500 Fax.: 0043.1.997150066 E-mail: crosse@2bepublished.at Skype: christoph.rosse Home: http://www.2bepublished.atOne of the shortcomings of namespaced functions in PHP is that it is not possible to import them as you can do with classes and namespaces. For code that is not in the same namespace as the function, you must always reference at least one part of the namespace in order to call it.What's wrong with referencing one part of it? It can be as short as two characters, and an an added bonus you won't suddenly have your strlen overridden by somebody without you knowing it. Functions live in global space, and there's a real lot of them, that's why importing them wasn't considered a good idea - it's going back to the same problem we were escaping with namespaces. Saving two keystrokes while sacrificing clarity is usually not the best idea. I don't know about your libraries but mine use longer namespace parts then 2 charakters.