Hi Marcus,

On Mon, 2008-03-03 at 13:27 +0100, Marcus Boerger wrote:
> new namespace::class()
> new namaespace::namedspace::class()
> 
> and so on, or:
> 
> namespace::class::functoin()
> namespace::function()
> 
> and so on. That is, when detecting braces after it and a new in front
> than it is a class. If there is no new in front it must be a function and
> autoload needs to be called for all but the last part. With new it needs
> to be called for all parts. Since the compiler already knows whether it
> generates a ctor call we must have an issue that should be fixable.

new in front is easy but take you're last example:

ns::func()

How can we detect, that we don't look for a class called "ns" with a
(static) method "func" but for a namespace "ns" with a regular function
called "func"? We do the lookup for "ns::func" in the function table,
then a class lookup for "ns" and then trigger autoload...

So the declaration for the thing called above could either look like

<?php
namespace ns;
function func() {}
?>

or like

<?php
class ns {
    static function func() {}
}
?>

And since we do only autoloading of classes, not functions, the autoload
is only triggered looking for the second case.

Every approach which might be cleverer would, imo, need some list of
known namespaces which the current design doesn't have at all.

johannes


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to