Hi!

> Back on the namespace topic. I won't judge on anything, but i know
> namespaces from c++. I understand that PHP isn't a compiled language
> and quite frankly that doesn't matter at all. What does matter is that
> PHP uses the name: "namespace" which C++ obviously had earlier.

Here is something that I would like to emphasize. There's no "one right
way" to do namespacing. And while PHP borrows a lot from other
languages, it was never promised or guaranteed that PHP would work
exactly like C++ or Java or Python or Ruby or any other language. If it
makes sense for PHP, it is taken in. If it's not, it is not taken.

In the case of namespaces, we needed to solve a particular problem of
PHP - global namespace pollution and people inventing super-long really
tedious names to deal with it. Moreover, it is in general *exactly* what
namespaces are solving in each language.  Namespaces were designed and
implemented to solve this particular problems, while keeping all other
parts of PHP working properly.

> Naturally someone that knows both languaes (c++ and php) simply assume
> that a namespace in php probably works the same as those in C++. If
> that's not the case then it shouldn't even carry the "namespace" name.

I couldn't disagree more. Namespace is a generic term, not belonging to
C++. PHP is not some offshoot of C++ that is required either behave like
C++ or stay away from it. Again, if it made sense in PHP to implement
*generic* concept of namespaces in a *particular way* that C++ does it -
we might do it. But it didn't, so we didn't. We have no responsibility
and no obligation to make implementations of generic concepts match
those in other languages or invent awkward names for those if they do
not. There's a value in behaving like other languages, but it only goes
so far.
Namespaces in PHP are as valid implementation of namespacing as those in
C++, they are just different. You came to it with prejudices about how
they should be working, these prejudices proved to be wrong, now you
know more and you continue to be more productive. This is natural and
happens to many people (myself included) quite often - one assumes
something, one is sometimes right and sometimes wrong. If one is wrong,
one corrects the mistake and becomes wiser. However I can't understand
how it makes sense to blame the language for not matching somebody's
personal background and prejudices.

> To me this namespace in php stuff just looks like and alias. So why
> isn't it named as that: "alias"? I do not want to question the ones
> that implemented namespaces in php, but i do think that the name
> itself is at the very least confusing.

It's not an alias. Aliasing is a part of it, but not the whole.
Declaration and the beginning of the file saying "alias My\Database"
makes little sense, declaration "namespace My\Database" makes great
sense - it shows that the file belongs to namespace My\Database, with
all consequences of that.

> Also, lets keep this discussion polite people. I'm not here to smash
> toes. All i would like to know is the reasoning behind the above and

I think I have explained the reasoning - specifically, why we have no
global imports - in my previous emails, but if you still have something
unclear, you are welcome to ask. It would make me happier though if you
tried to read through the archives where namespaces were discussed and
see all those arguments so we won't have to repeat them again, even
though I understand that nobody really does that :)

> if there is any intention of changing the namespaces to be more c++
> like.

I would evaluate the chances of it as very small and I would be in a
very vocal and active opposition to that.
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to