473,321 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

PHP's global namespace

Why are PHP's system functions all in a global namespace?

Won't this lead to chaos as new functions are added, which have names
which clash with user-defined functions?
--
__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.
Jul 17 '05 #1
11 8526
Tim Tyler wrote:
Why are PHP's system functions all in a global namespace?

Won't this lead to chaos as new functions are added, which have names
which clash with user-defined functions?


simple : do not use php functions as your own names. this would conflict
in ANY language!

regards

timo

Jul 17 '05 #2
Timo Henke <ti******@fli7e.de> wrote or quoted:
Tim Tyler wrote:
Why are PHP's system functions all in a global namespace?

Won't this lead to chaos as new functions are added, which have names
which clash with user-defined functions?


simple : do not use php functions as your own names.


I was talking about new functions added to PHP.

Avoiding those would apparently require precognition.

Rarely have I seen user functions going into such a crowded namespace -
picking function names feels a bit like navigating a minefield.
this would conflict in ANY language!


Other languages don't put all their functions straight into a global namespace.
--
__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.
Jul 17 '05 #3
Tim Tyler wrote:
Other languages don't put all their functions straight into a global
namespace.


I think this issue has more to do with the fact namespaces arn't a feature
of PHP. They will be included in PHP5.

Kind Regards,

--
Ian P. Christian
Jul 17 '05 #4
On Sat, 18 Oct 2003 11:30:30 +0100, "Ian P. Christian" <po****@pookey.co.uk>
wrote:
Tim Tyler wrote:
Other languages don't put all their functions straight into a global
namespace.


I think this issue has more to do with the fact namespaces arn't a feature
of PHP. They will be included in PHP5.


The last I heard the developers changed their minds on that, and they're not
going to be implemented.

Which is a big shame, because name clashes are inevitable once there's enough
people working on a PHP project, or you use several libraries in one script.

http://news.php.net/article.php?grou...s&article=2124

Hopefully they will, or already have, reversed that decision.

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #5
Andy Hassall wrote:
On Sat, 18 Oct 2003 11:30:30 +0100, "Ian P. Christian"
<po****@pookey.co.uk> wrote:
Tim Tyler wrote:
Other languages don't put all their functions straight into a global
namespace.


I think this issue has more to do with the fact namespaces arn't a feature
of PHP. They will be included in PHP5.


The last I heard the developers changed their minds on that, and they're
not
going to be implemented.

Which is a big shame, because name clashes are inevitable once there's
enough
people working on a PHP project, or you use several libraries in one
script.


Oh, that is a shame :(

I personally use classes though to provide namespaceish functionality.

Auth::getAuth(); etc. etc.

Kind Regards,

--
Ian P. Christian
Jul 17 '05 #6
Tim Tyler:
Timo Henke <ti******@fli7e.de> wrote or quoted:
Tim Tyler wrote:

Why are PHP's system functions all in a global namespace?

Won't this lead to chaos as new functions are added, which have names
which clash with user-defined functions?


simple : do not use php functions as your own names.


I was talking about new functions added to PHP.

Avoiding those would apparently require precognition.

Rarely have I seen user functions going into such a crowded namespace -
picking function names feels a bit like navigating a minefield.


In my 4 years of PHP experience this has not been a problem for me. I can't
remember ever being bothered by this feature of PHP. It's seems like a
terrible idea, but it doesn't really work that bad.

André Næss
Jul 17 '05 #7
Tim Tyler wrote:
Why are PHP's system functions all in a global namespace?

Won't this lead to chaos as new functions are added, which have names
which clash with user-defined functions?


Functions typically have a library prefix to get around this:
array_sort()
preg_replace()
..
..
..

It would be nice if this convention were refined and the old functions
would be removed in PHP 5.
Jul 17 '05 #8
With total disregard for any kind of safety measures Keith Bowes
<do****@spam.me> leapt forth and uttered:
It would be nice if this convention were refined and the old
functions would be removed in PHP 5.


Or at least a series of function aliases put in place that define a
proper naming standard whilst maintaining a certain degree of
backwards-compatibility.

I don't see why this would cause noticable overhead. Many existing
functions already have more than one name.

--
There is no signature.....
Jul 17 '05 #9
Tim Tyler <ti*@tt1lock.org> wrote in message
news:<HM********@bath.ac.uk>...

Why are PHP's system functions all in a global namespace?
Because there is no concept of namespace in PHP, I believe.
Won't this lead to chaos as new functions are added, which
have names which clash with user-defined functions?


Highly unlikely, especially given the fact that all functions
added after a certain point are prefixed with their extension
name (imap_*, ldap_*, mysql_*, etc.). If you are concerned
with namespace issues, you might as well adopt a similar
approach and prefix all your functions in a similar fashion.

Cheers,
NC
Jul 17 '05 #10
Nikolai Chuvakhin <nc@iname.com> wrote or quoted:
If you are concerned with namespace issues, you might as well adopt a
similar approach and prefix all your functions in a similar fashion.


Namespaces via a naming convention seems like a hack to me.

For one thing, it fails to make referring to things in your
"own" namespace any easier.

Wouldn't it be better to use classes for this purpose?
--
__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.
Jul 17 '05 #11
Tim Tyler <ti*@tt1lock.org> wrote in message
news:<Hn********@bath.ac.uk>...
Nikolai Chuvakhin <nc@iname.com> wrote or quoted:
If you are concerned with namespace issues, you might as well adopt a
similar approach and prefix all your functions in a similar fashion.
Namespaces via a naming convention seems like a hack to me.


But it's an easy one; that's what counts in a language that, above all,
is supposed to be simple.
For one thing, it fails to make referring to things in your
"own" namespace any easier.
This is by and large a matter of personal taste. You want your
own namespace because having it makes you feel more comfortable.
I don't want my own namespace because having it makes me feel
less comfortable.
Wouldn't it be better to use classes for this purpose?


To some people, yes. To an old-fashioned procedural type like yours
truly, it's an unnecessary and potentially wasteful hassle.

Cheers,
NC
Jul 17 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

88
by: Tim Tyler | last post by:
PHP puts most of its functions into a big flat global namespace. That leads to short function names - but creates a namespace minefield for programmers. Lots of the functions are legacies from...
26
by: Joshua Beall | last post by:
Hi All, I remember reading that both nested classes and namespaces would be available in PHP5. I know that namespaces got canceled (much sadness...), however, I *thought* that nested classes...
2
by: Tony Johansson | last post by:
Hello! I'm reading a book about C++ and there is something that I don't understand so I ask you. Below I have the text from the book and the code from the file where main is located and some...
7
by: Citrus | last post by:
Hey, i'm looking for the best possible way for connecting to my database without too much of an effort. The example works fine and fast. What i need to know is if it's safe, stable and the way...
1
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.