Hi, well, my apologies for not making that clear enough. I suppose it wouldn't require any runtime information, as this kind of construct could be expanded at compile time.
For example: <?php namespace LibraryWithAVeryLongName; // Setting up a service container, like Phemto, as of PHP 5.3.3 $container->willUse('LibraryWithAVeryLongName\Cache\FileCache') ->willUse('LibraryWithAVeryLongName\Routing\CachingRouter') ->willUse('LibraryWithAVeryLongName\Parsing\CachingParser'); // tens of similar declarations follow // Mentioning a class name in an exception message throw new \InvalidArgumentException('The first argument must be an array or an instance of LibraryWithAVeryLongName\Collections\List'); ?> Now if there was a COMPILE-TIME construct for expanding unqualified names and "quoting" them, i.e. turning them into string literals, then the 'LibraryWithAVeryLongName' prefix would be redundant, because it's already declared as the current namespace. In Java, there is the Foo.class syntax. C# has typeof(Foo). So something like class(Foo) would be nice to have in PHP. Even if such long namespace names as in the example don't make sense, deeply-nested ones do, so that's hardly an exaggeration. Now, an example using the proposed syntax: <?php namespace LibraryWithAVeryLongName; $container->willUse(class(Cache\FileCache)) ->willUse(class(Routing\CachingRouter)) ->willUse(class(Parsing\CachingParser)); // and so on use LibraryWithAVeryLongName\Collections\List; throw new \InvalidArgumentException('The first argument must be an array or an instance of ' . class(List)); ?> And of course, class(Foo) doesn't have to be the exact syntax. On 8/5/10, Stas Malyshev <smalys...@sugarcrm.com> wrote: > Hi! > >> unqualified aliases, it would be useful to extend this functionality >> to string references to these classes/functions/constants as well. > > It would require to carry "namespace context" around with every > function/class in runtime and for me the usecase is not clear. Can you > describe more in detail what you try to do and why you need runtime > resolution for it? > -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 > -- Sent from my mobile device -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php