By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,207 Members | 1,028 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,207 IT Pros & Developers. It's quick & easy.

Namespaces in PHP5, removed?

P: n/a
Hi All,

I read in a forum somewhere that namespaces, though once supposed to be a
part of PHP5, have been removed. Is this true? Can anyone show me the
official statement by Zend that they decided to forget about namespaces?
Why would they do this?

I could really use namespaces. If they canned this idea, that is quite a
disappointment :-/ Guess you cannot win them all.

-Josh
Jul 17 '05 #1
Share this Question
Share on Google+
14 Replies


P: n/a
With total disregard for any kind of safety measures "Joshua
Beall" <jb****@donotspam.remove.me.heraldic.us> leapt forth and
uttered:
Hi All,

I read in a forum somewhere that namespaces, though once
supposed to be a part of PHP5, have been removed. Is this true?
Can anyone show me the official statement by Zend that they
decided to forget about namespaces? Why would they do this?


From the Zend changelog:

Version 5.0.0 Beta 2
30-Oct-2003
Lots and lots of changes in the Zend Engine 2 since beta 1:
* Removed the not so working namespaces support

I've lost the links to the original reasonings given by Andi
Gutmans and Zeev Suraski, but heres one link:

http://www.sitepoint.com/forums/show...5&postcount=34
--
Phil Roberts | Nobody In Particular | http://www.flatnet.net/
Jul 17 '05 #2

P: n/a
Because it was pretty pointless that way it was implemented. You can't
import names from a namespace, so everytime you use something from within
it, you have to tag on the namespace identifier.

Uzytkownik "Joshua Beall" <jb****@donotspam.remove.me.heraldic.us> napisal w
wiadomosci news:iG******************@nwrddc01.gnilink.net...
Hi All,

I read in a forum somewhere that namespaces, though once supposed to be a
part of PHP5, have been removed. Is this true? Can anyone show me the
official statement by Zend that they decided to forget about namespaces?
Why would they do this?

I could really use namespaces. If they canned this idea, that is quite a
disappointment :-/ Guess you cannot win them all.

-Josh

Jul 17 '05 #3

P: n/a
"Chung Leong" <ch***********@hotmail.com> wrote in message
news:ZY********************@comcast.com...
Because it was pretty pointless that way it was implemented. You can't
import names from a namespace, so everytime you use something from within
it, you have to tag on the namespace identifier.


That's too bad. I wonder, how well can I emulate namespaces using nested
classes? Is there any way to "import" the contents of a class?
Jul 17 '05 #4

P: n/a
Joshua Beall wrote:
Hi All,

I read in a forum somewhere that namespaces, though once supposed to
be a part of PHP5, have been removed. Is this true? Can anyone show
me the official statement by Zend that they decided to forget about
namespaces? Why would they do this?


Quote from http://www.php.net/ChangeLog-5.php (version 5.0.0 beta 2,
30-Oct-2003):

"Removed the not so working namespaces support"

I don't know why exactly, but I have a feeling the developers wanted to
focus on other parts of PHP 5 instead.
JW

Jul 17 '05 #5

P: n/a
Personally, I never liked namespace. Its need is understandable in C++,
where you link in binary libraries and there's no other workaround for name
collisions. With PHP you can just rename the class/function. And namespace
promotes bloated class libraries, which affects runtime performance in PHP.
When the number of classes is large enough where name collision is an issue,
you scripts are probably all crawling.

Uzytkownik "Joshua Beall" <jb****@donotspam.remove.me.heraldic.us> napisal w
wiadomosci news:kL******************@nwrddc02.gnilink.net...
"Chung Leong" <ch***********@hotmail.com> wrote in message
news:ZY********************@comcast.com...
Because it was pretty pointless that way it was implemented. You can't
import names from a namespace, so everytime you use something from within it, you have to tag on the namespace identifier.


That's too bad. I wonder, how well can I emulate namespaces using nested
classes? Is there any way to "import" the contents of a class?

Jul 17 '05 #6

P: n/a
Chung Leong writes:
Personally, I never liked namespace. Its need is understandable in C++,
where you link in binary libraries and there's no other workaround for name
collisions. With PHP you can just rename the class/function.
You mean search and replace for every occurance of the duplicate
class? It's feasible, but not always very practical, and you need to
know that a name collision exists to begin with. The best practical
alternative to namespaces is a class naming convention, and that has
its own problems.
And namespace promotes bloated class libraries, which affects
runtime performance in PHP. When the number of classes is large
enough where name collision is an issue, you scripts are probably
all crawling.


Only if you include them all at once. You could have a vast library
of classes available, but only include the ones you need as you need
them. Or leave it to the optimiser to cache your classes. For PHP to
be taken seriously as an enterprise programming language, it must be
possible to write large systems in it. Namespaces make large systems
easier to write.

Apart from name collision prevention, namespaces also provide another
scope for class member access. Classes in the same namespace can
access each others members, but deny access to classes outside the
namespace. Without namespaces you must declare such members public
and hope for the best.

--

__o Alex Farran
_`\<,_ Analyst / Programmer
(_)/ (_) www.alexfarran.com

Jul 17 '05 #7

P: n/a
Being a incorrigible PHP Maoist, I say down with class hierarchy and screw
private variable.

Long live the global scope!

Uzytkownik "Alex Farran" <al**@alexfarran.com> napisal w wiadomosci
news:m3************@alexfarran.com...
Chung Leong writes:
Personally, I never liked namespace. Its need is understandable in C++,
where you link in binary libraries and there's no other workaround for name collisions. With PHP you can just rename the class/function.


You mean search and replace for every occurance of the duplicate
class? It's feasible, but not always very practical, and you need to
know that a name collision exists to begin with. The best practical
alternative to namespaces is a class naming convention, and that has
its own problems.
And namespace promotes bloated class libraries, which affects
runtime performance in PHP. When the number of classes is large
enough where name collision is an issue, you scripts are probably
all crawling.


Only if you include them all at once. You could have a vast library
of classes available, but only include the ones you need as you need
them. Or leave it to the optimiser to cache your classes. For PHP to
be taken seriously as an enterprise programming language, it must be
possible to write large systems in it. Namespaces make large systems
easier to write.

Apart from name collision prevention, namespaces also provide another
scope for class member access. Classes in the same namespace can
access each others members, but deny access to classes outside the
namespace. Without namespaces you must declare such members public
and hope for the best.

--

__o Alex Farran
_`\<,_ Analyst / Programmer
(_)/ (_) www.alexfarran.com

Jul 17 '05 #8

P: n/a
Alex Farran <al**@alexfarran.com> wrote or quoted:
For PHP to be taken seriously as an enterprise programming language, it
must be possible to write large systems in it. Namespaces make large
systems easier to write.


Yes - exactly.

Still - PHP has some other problems - as a result of being hastily hacked
together - I can imagine why the developers might want to focus on those ;-)
--
__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.
Jul 17 '05 #9

P: n/a

"Alex Farran" <al**@alexfarran.com> wrote in message
news:m3************@alexfarran.com...
Chung Leong writes:
Personally, I never liked namespace. Its need is understandable in C++,
where you link in binary libraries and there's no other workaround for name collisions. With PHP you can just rename the class/function.
You mean search and replace for every occurance of the duplicate
class? It's feasible, but not always very practical, and you need to
know that a name collision exists to begin with. The best practical
alternative to namespaces is a class naming convention, and that has
its own problems.


Naming conventions require intelligence, which sadly is in short supply.
And namespace promotes bloated class libraries, which affects
runtime performance in PHP. When the number of classes is large
enough where name collision is an issue, you scripts are probably
all crawling.


Only if you include them all at once. You could have a vast library
of classes available, but only include the ones you need as you need
them. Or leave it to the optimiser to cache your classes. For PHP to
be taken seriously as an enterprise programming language, it must be
possible to write large systems in it. Namespaces make large systems
easier to write.


I have wriitten large systems in several languages which did not have
namespaces, so namespaces cannot be the only solution to that problem
(whatever the "problem" is). If you identified the problem correctly, then
perhaps a solution other than namespaces would present itself.

Tony Marston
http://www.tonymarston.net/
Apart from name collision prevention, namespaces also provide another
scope for class member access. Classes in the same namespace can
access each others members, but deny access to classes outside the
namespace. Without namespaces you must declare such members public
and hope for the best.

--

__o Alex Farran
_`\<,_ Analyst / Programmer
(_)/ (_) www.alexfarran.com

Jul 17 '05 #10

P: n/a
Tony Marston writes:
I have wriitten large systems in several languages which did not have
namespaces, so namespaces cannot be the only solution to that problem
(whatever the "problem" is). If you identified the problem correctly, then
perhaps a solution other than namespaces would present itself.


The problem is name collision, which is going to happen sooner or
later when you have more than one person working on a project,
possibly seperated by time and distance. You solve it by either
making sure each class and function has a unique name, ie using a
naming convention, or by using namespaces so it doesn't matter if they
don't.

If I write a library I have no way of knowing where that library is
going to be used, or which other librarys may be in use at the same
time. I need some way of ensuring that my class and function names
will not conflict with anyone elses.

--

__o Alex Farran
_`\<,_ Analyst / Programmer
(_)/ (_) www.alexfarran.com

Jul 17 '05 #11

P: n/a
Sorry, typos.
If I write a library I have no way of knowing where that library is
going to be used, or which other librarys may be in use at the same libraries time. I need some way of ensuring that my class and function names
will not conflict with anyone elses.

else's.
--

__o Alex Farran
_`\<,_ Analyst / Programmer
(_)/ (_) www.alexfarran.com

Jul 17 '05 #12

P: n/a
Clearly, if a team of developers continually have name collisons, they are
not making any kind of effort to reuse each other's code. I don't see how a
project can suceed when there's such a massive communication problem.

Uzytkownik "Alex Farran" <al**@alexfarran.com> napisal w wiadomosci
news:m3************@alexfarran.com...
The problem is name collision, which is going to happen sooner or
later when you have more than one person working on a project,
possibly seperated by time and distance. You solve it by either
making sure each class and function has a unique name, ie using a
naming convention, or by using namespaces so it doesn't matter if they
don't.

If I write a library I have no way of knowing where that library is
going to be used, or which other librarys may be in use at the same
time. I need some way of ensuring that my class and function names
will not conflict with anyone elses.

--

__o Alex Farran
_`\<,_ Analyst / Programmer
(_)/ (_) www.alexfarran.com

Jul 17 '05 #13

P: n/a
Chung Leong writes:
Clearly, if a team of developers continually have name collisons, they are
not making any kind of effort to reuse each other's code. I don't see how a
project can suceed when there's such a massive communication problem.


In a small team it is reasonable to assume, even expect, detailed
knowledge of each others code. Namespaces would be a convenience, but
hardly essential. As teams grow the communication overhead reduces
their efficiency (I believe the optimum size is 4). Larger projects
are subdivided into teams. A team member has detailed knowledge of
the code in their project area, and less detailed knowledge of related
areas. No one has detailed knowledge of the whole project, so to
avoid name collisions you must have a system. Namespaces is one, a
naming convention is another.

--

__o Alex Farran
_`\<,_ Analyst / Programmer
(_)/ (_) www.alexfarran.com

Jul 17 '05 #14

P: n/a
A large project doesn't imply one large application though. It's easy
enough--perhaps the wisest thing to do--to divide up a web application into
smaller ones, with the codebases that don't interact.

Uzytkownik "Alex Farran" <al**@alexfarran.com> napisal w wiadomosci
news:m3************@alexfarran.com...
Chung Leong writes:
Clearly, if a team of developers continually have name collisons, they are not making any kind of effort to reuse each other's code. I don't see how a project can suceed when there's such a massive communication problem.


In a small team it is reasonable to assume, even expect, detailed
knowledge of each others code. Namespaces would be a convenience, but
hardly essential. As teams grow the communication overhead reduces
their efficiency (I believe the optimum size is 4). Larger projects
are subdivided into teams. A team member has detailed knowledge of
the code in their project area, and less detailed knowledge of related
areas. No one has detailed knowledge of the whole project, so to
avoid name collisions you must have a system. Namespaces is one, a
naming convention is another.

--

__o Alex Farran
_`\<,_ Analyst / Programmer
(_)/ (_) www.alexfarran.com

Jul 17 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.