Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34260 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10753 invoked by uid 1010); 27 Dec 2007 08:29:39 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 10738 invoked from network); 27 Dec 2007 08:29:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Dec 2007 08:29:38 -0000 Authentication-Results: pb1.pair.com header.from=hans.moog@mkj-computing.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=hans.moog@mkj-computing.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mkj-computing.de from 78.47.136.132 cause and error) X-PHP-List-Original-Sender: hans.moog@mkj-computing.de X-Host-Fingerprint: 78.47.136.132 static.132.136.47.78.clients.your-server.de Received: from [78.47.136.132] ([78.47.136.132:59895] helo=webserver.mkjc.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D1/60-07589-26263774 for ; Thu, 27 Dec 2007 03:29:29 -0500 Received: (qmail 17134 invoked from network); 27 Dec 2007 09:55:09 +0100 Received: from unknown (HELO win-001.server-ip.de) (78.47.136.133) by hjp-solutions.de with SMTP; 27 Dec 2007 09:55:09 +0100 Date: Thu, 27 Dec 2007 09:28:38 +0100 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C84862.7CD02D3A" Message-ID: <7C37FF3A0196094F95430BA95952032211BA43@s1.mkj.lan> X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-class: urn:content-classes:message Thread-Topic: Suggestion: Namespace implementation X-MimeOLE: Produced By Microsoft Exchange V6.5 thread-index: AchIYnqCODvpHYfQT6yoxmKxLya3BQ== To: Subject: Suggestion: Namespace implementation From: hans.moog@mkj-computing.de ("Hans Moog") ------_=_NextPart_001_01C84862.7CD02D3A Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Within the last few days i read some of the posts concerning the new namespace implementation and it's alleged problems. And ... I really have to say, that I do not understand whats the problem with namespaces at all. Instead, I suppose that many lost sight of the original goal of namespaces. =20 In my oppinion namespaces should only be an additional way of structering php elements and using short names again without loosing the abilitiy to avoid naming conflicts with 3rd party libraries. Since libraries are generally class libraries and because of already being able to group variables, constants and functions in static classes i see no reason for namespaces to affect the resolution of the previously mentioned elements. Instead, they should only affect classes enabling the coder to tie packages and use or provide libraries. =20 =20 By the way ... why should it be possible to write something like this: =20 =20 to express "Array::merge()". =20 If we are already able to express the same thing by writing something like this: =20 =20 even leaving us the opportunity to later group the static classes into an additional package by additionally defining a namespace in the file. If we decide to limit namespaces to classes, we are able to define some very easy rules that are able to be applied during compile time without having any runtime evaluation, making namespaces really fast: =20 =20 If there is a namespace declaration in the current file { 1. all classes defined in this file are prefixed with the namespace. 2. all classes without an additional namespace prefix (meaning everything with X::) which were not imported are prefixed with the defined namespace. 3. all classes with a name that was imported get resolved by replacing the imported alias with the imported path. 4. all other classes (especially Y::X::) that were not imported are resolved as beeing full paths (remaining unmodified) } else { 1. all classes defined in this file are not prefixed with a namespace 2. all classes without an additional namespace prefix (meaning everything with X::) which were not imported are NOT prefixed. 3. all classes with a name that was imported get resolved by replacing the imported alias with the imported path. 4. all other classes (especially Y::X::) that were not imported are resolved as beeing full paths (remaining unmodified) } =20 =20 =20 Example with a namespace declaration: =20 =20 will be compiled to: =20 =20 =20 =20 =20 Example without a namespace declaration: =20 =20 will be compiled to: =20 =20 =20 So ... we would be able have short names without being scared of naming conflicts with core functions or breaking backward compatibility. And we would still be able to express the same things as if we would allow namespace for functions, variables and constants by declaring them in static classes. =20 =20 PS: Just a suggestion so don't kill me :o) ------_=_NextPart_001_01C84862.7CD02D3A--