Re: Namespaces in PHP5, removed?
From: Alex Farran (alex_at_alexfarran.com)
Date: 02/07/04
- Next message: John Dunlop: "Re: simple regex problem"
- Previous message: BjoernJackschina: "cancel a text lines"
- In reply to: Chung Leong: "Re: Namespaces in PHP5, removed?"
- Next in thread: Tim Tyler: "Re: Namespaces in PHP5, removed?"
- Reply: Tim Tyler: "Re: Namespaces in PHP5, removed?"
- Reply: Tony Marston: "Re: Namespaces in PHP5, removed?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 07 Feb 2004 20:27:12 +0000
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
- Next message: John Dunlop: "Re: simple regex problem"
- Previous message: BjoernJackschina: "cancel a text lines"
- In reply to: Chung Leong: "Re: Namespaces in PHP5, removed?"
- Next in thread: Tim Tyler: "Re: Namespaces in PHP5, removed?"
- Reply: Tim Tyler: "Re: Namespaces in PHP5, removed?"
- Reply: Tony Marston: "Re: Namespaces in PHP5, removed?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|