You can import a namespace and use an alias. For instance use com\example\cms as c;
c\foo(); -----Ursprüngliche Nachricht----- Von: Christoph Rosse [mailto:cro...@2bepublished.at] Gesendet: Freitag, 19. April 2013 14:48 An: internals@lists.php.net Betreff: Re: [PHP-DEV] Importing namespaced functions On 19.04.2013 08:19, Stas Malyshev wrote: > Hi! > >> One 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. 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: cro...@2bepublished.at Skype: christoph.rosse Home: http://www.2bepublished.at -- 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