473,372 Members | 841 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,372 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 8530
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.