Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:26547 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35331 invoked by uid 1010); 14 Nov 2006 04:00:48 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 35316 invoked from network); 14 Nov 2006 04:00:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Nov 2006 04:00:48 -0000 X-Host-Fingerprint: 70.149.56.82 adsl-149-56-82.mia.bellsouth.net Received: from [70.149.56.82] ([70.149.56.82:22784] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 95/78-60788-E6F39554 for ; Mon, 13 Nov 2006 23:00:48 -0500 Message-ID: <95.78.60788.E6F39554@pb1.pair.com> To: internals@lists.php.net Date: Mon, 13 Nov 2006 23:00:42 -0500 User-Agent: Thunderbird 1.5.0.7 (X11/20060913) MIME-Version: 1.0 References: <4554AE0D.4080600@caedmon.net> <99.20.32592.5ED45554@pb1.pair.com> <19674119.20061111112203@marcus-boerger.de> <3D.90.24000.85F66554@pb1.pair.com> <4557017A.3020804@gmail.com> In-Reply-To: <4557017A.3020804@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 70.149.56.82 Subject: Re: [PHP-DEV] Re: Namespaces in PHP 6 - ++$take From: jrhernandez05@gmail.com (Jessie Hernandez) What does everyone else think? Are functions/constants inside namespaces really that critical? Anyways, I just thought of a possible solution to the namespace separator issue, and if it's doable, then the double colon (::) can even be used and no conflicts would occur. It seems the biggest problem with handling namespaces is determining if a symbol is a class or namespace at compile-time. I am no expert in flex/bison, but I was thinking that a state can be used, such as LOOKING_FOR_CLASS_OR_NAMESPACE, which will return either a T_CLASS_NAME or T_NAMESPACE_NAME token depending on whether the symbol is known to be a class or namespace. The user will add either a "using" or "import" statement before the use of the symbol, and this will allow the parser to know what that symbol is in the compilation phase. As an example: // BEGIN CODE using namespace PEAR::File; $items = File::Find::glob( '!.*\.php$!', $dir, 'perl' ); // END CODE The first statement will add an entry into a hashtable (used during compilation) indicating that "PEAR", "PEAR::File", and "File" are namespaces ("File" will be imported in the current file only). When "File::Find::glob" is parsed, the compiler already knows that "File" is a namespace, so "Find" must be a class inside that namespace, and "glob" must be a static method. With this, functions and constants can easily be added inside namespaces, as the "using" or "import" statement will indicate to the parser which portion of the qualified name is a namespace. Is this feasible in flex/bison? Let me know if anything needs clarification. Regards, Jessie Hernandez Stefan Walk wrote: > Hi! > > If the namespace-approach only covers classes it is implemented > half-heartedly, IMO. I see a lot of "classes" that are just really > collections of static functions, that's what namespaces should cover, > too. And disallowing constants only so that : works is a bad tradeoff... > > Regards, > Stefan