Why? I think namespace is a good method to seperate classes.
Why there's no namespace keyword in php5?
Collapse
This topic is closed.
X
X
-
YarcoTags: None -
Janwillem Borleffs
Re: Why there's no namespace keyword in php5?
Yarco wrote:[color=blue]
> Why? I think namespace is a good method to seperate classes.
>[/color]
The early PHP5 alpha releases supported namespaces, but as the
developers never got it to work properly, they left it out in the PHP
5.x branch.
JW
-
Andy Hassall
Re: Why there's no namespace keyword in php5?
On Mon, 10 Oct 2005 12:19:47 +0200, Janwillem Borleffs <jw@jwscripts.c om>
wrote:
[color=blue]
>Yarco wrote:[color=green]
>> Why? I think namespace is a good method to seperate classes.[/color]
>
>The early PHP5 alpha releases supported namespaces, but as the
>developers never got it to work properly, they left it out in the PHP
>5.x branch.[/color]
The text of the proposed namespace syntax is still in the PHP source
distribution, see $PHP_SRC/Zend/RFCs/002.txt - although in the header it says
"Status: declined".
--
Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Comment
-
Tony Marston
Re: Why there's no namespace keyword in php5?
"Yarco" <yarco.w@gmail. com> wrote in message
news:1128921308 .287536.206170@ g44g2000cwa.goo glegroups.com.. .[color=blue]
> Why? I think namespace is a good method to seperate classes.[/color]
Giving each class a different name is usually good enough. If you have
classes with identical names from different 3rd party suppliers then keep
them in different directories. Personally I cannot see what all the fuss
with namespaces is about. I have been programming for 30 years with a
variety of 2nd, 3rd and 4th generation languages and I have never used
namespaces.
Perhaps that is the only solution you have been taught, but it is certainly
not the only solution out there.
--
Tony Marston
This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL
Comment
-
Yarco
Re: Why there's no namespace keyword in php5?
> Giving each class a different name is usually good enough...
It may get longer...
For example, non-namespace:
class Tony_db
{
const MYSQL='mysql';
//...
}
So, i should use Tony_db::MYSQL to use it.
But if i have namespace.
namespace Tony
{
class db
{
const MYSQL='mysql';
}
}
and then, i can coding:
using namespace Tony;
db::MYSQL
Comment
-
Yarco
Re: Why there's no namespace keyword in php5?
So...there might be:
$db = Tony_db::getIns t(Tony_db::MYSQ L);
vs
using namespace Tony;
$db = db::getInst(db: :MYSQL);
And when using namespace myself, i can only change the namespace "Tony"
to "Yarco".
But when change class, i should do it line by line, or using some
automatic modifier.
Comment
-
Weird-beard
Re: Why there's no namespace keyword in php5?
another benefit of being able to use namespaces is providing another
layer of encapsulation, defining visibility for classes, hiding
unneeded info from the namespaces different than the current.
I think that's more important than the name collision. About the
naming,using frameworks or 3rd party modules etc. results in name
collisions most of the time, and working as a team may result in weird
names.
Eg. Namespace A
{
private class B
{}
public Class c
}
Namespace D
{
private class E
{
instC=new C(); // OK
instB=new B(); // Not Accessible
}
}
Comment
Comment