Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:26514 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81050 invoked by uid 1010); 11 Nov 2006 10:21:17 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 81034 invoked from network); 11 Nov 2006 10:21:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Nov 2006 10:21:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=helly@php.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=helly@php.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain php.net from 81.169.182.136 cause and error) X-PHP-List-Original-Sender: helly@php.net X-Host-Fingerprint: 81.169.182.136 ajaxatwork.net Linux 2.4/2.6 Received: from [81.169.182.136] ([81.169.182.136:60133] helo=strato.aixcept.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 48/33-47982-A14A5554 for ; Sat, 11 Nov 2006 05:21:15 -0500 Received: from baumbart.mbo (dslb-084-063-000-233.pools.arcor-ip.net [84.63.0.233]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by strato.aixcept.de (Postfix) with ESMTP id F05B961029E; Sat, 11 Nov 2006 11:21:10 +0100 (CET) Date: Sat, 11 Nov 2006 11:22:03 +0100 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <19674119.20061111112203@marcus-boerger.de> To: Jessie Hernandez Cc: internals@lists.php.net In-Reply-To: <99.20.32592.5ED45554@pb1.pair.com> References: <4554AE0D.4080600@caedmon.net> <99.20.32592.5ED45554@pb1.pair.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: Namespaces in PHP 6 - ++$take From: helly@php.net (Marcus Boerger) Hello Jessie, sorry to say this but look at the following, keeping in mind that the whitespace is optional. $x = $foo ? class:const : $var // 1, 0 $x = $foo ? class:const : const; // 1, 0 $x = $foo ? class:const : class:const; // 1, 1 $x = $foo ? class:const : namespace:class:const; // 1, 2 $x = $foo ? namespace:class:const : $var; // 2, 0 $x = $foo ? namespace:class:const : const; // 2, 0 $x = $foo ? namespace:class:const : class:const; // 2, 1 $x = $foo ? namespace:class:const : namespace:class:const; // 2, 2 Feel free to continue that list, it has conflicts whatever you do. Saturday, November 11, 2006, 5:13:22 AM, you wrote: > Hello, > I haven't had time to work on my patch, but thinking about this some > more, I'm convinced namespaces should only contain classes. The only > problem that was present when permitting functions/constants to be > inside namespaces was the ambiguity in ternary expressions. By just > supporting classes inside namespaces, this issue would go away. Besides, > I'll dare say that most, if not all, the developers who want namespaces > will only group classes with it anyways, > Also, by only supporting classes, we can use ":" instead of the long > ":::" separator and everyone would be happy. > Last I checked, the only things that were pending on my patch were some > scoping issues which I had to fix. These are listed below. Once these > are done, the patch can be formally proposed. If anyone wants to take a > look at the patch so far and/or work on the remaining issues below, let > me know and I'll either post the patch or email it. > Pending: > 1) The extends clause should resolve imported class names. > import class ns:DateBase; > namespace ns{ class Date extends DateBase{} } > 2) To access a global symbol, use global: syntax. I would prefer ':::' or '\' but that doesn't really matter as we have 'global' as a keyword already. > 3) Type hints should also consider imported classes. > 4) When an import is done (with alias or not), and a global class with > that same name exists, what is the desired behavior? Error? Global takes > precedence? Maybe this new discussion gave one hint. Aliases could be solved with a flag. Just copy the classwith a new name into the classlist again and flagit as copy. Maybe the original class gets a list of the copies of the copies a pointer to the original but that would be an implementation detail. As soon as that is done importdoes nothingelse then copying classes on a single class table. That said namespaces would, if after all, simply contain other copies to the original classes. In the extremecase we can start with namespaces only being a 'stupid' list. Reflection could then travers all classes to see in which namespaces it was registered. This btw would also fix 3) as the namespace seperator would be a normal sign in class lookup, it would simply be disallowed in definitions of class/interface/namespaces. Best regards, Marcus