Re: phpnamespaces.org!
| From: | Ron Korving | Date: | Fri, 02 Dec 2005 07:41:52 +0000 |
| Subject: | Re: phpnamespaces.org! | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-20989@lists.php.net to get a copy of this message | ||
I assume ::: is being used because it simply works and the discussion on
which seperator to use might still go on for some time ;). You have a point
about import statements being allowed only in the beginning. This would be
nice:
class X
{
public function foo()
{
import class bar:::MyClass;
$obj = new MyClass();
$obj->doSomething();
}
}
This would be nice, because __autoload() only needs to be called if my
method foo() is being called. bar:::MyClass is not a dependency for the
whole file, but only for X::foo(). Performance-wise it would be a good thing
if importing namespaces would not extend the dependency to the whole file.
Also, it could prevent unnecessary aliasing:
class X
{
public function foo()
{
import class bar:::MyClass;
$obj = new MyClass();
$obj->doSomething();
}
public function fubar()
{
import class bla:::MyClass;
$obj = new MyClass();
$obj->doSomething();
}
}
In this example, bar:::MyClass and bla:::MyClass are used. Two different
classes, each in their own namespace. Aliasing is not required, because the
imported namespaces are limited to the scope of the methods foo() and
fubar().
- Ron
"Marian Kostadinov" <manchokapitancho@gmail.com> schreef in bericht
news:bec76cf90512012309u6e85d2dcg@mail.gmail.com...
First I must say - a nice job:)
The namespaced version works fine.
I found just 3 problems (things I don't like):
1.Import statements are allowed only in the beginning of the script.
2.Global function calls are not allowed in a namespace.
3.The example below does not work.
<?
import class ABC:::TEST as ABC_TEST;
import function ABC:::FUNC;
namespace ABC {
class TEST {}
function FUNC() {
new TEST;
}
}
FUNC();
?>
Anyway, the patch seems to be stable.
Also ::: is veeery long. I wrote it a lot of times and usually I got
:: instead of :::