Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:40409 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70542 invoked from network); 9 Sep 2008 14:38:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Sep 2008 14:38:53 -0000 Authentication-Results: pb1.pair.com header.from=greg@chiaraquartet.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=greg@chiaraquartet.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain chiaraquartet.net from 208.83.222.18 cause and error) X-PHP-List-Original-Sender: greg@chiaraquartet.net X-Host-Fingerprint: 208.83.222.18 unknown Linux 2.6 Received: from [208.83.222.18] ([208.83.222.18:58012] helo=mail.bluga.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6E/20-23799-D7A86C84 for ; Tue, 09 Sep 2008 10:38:53 -0400 Received: from mail.bluga.net (localhost.localdomain [127.0.0.1]) by mail.bluga.net (Postfix) with ESMTP id A3E8B98DC63 for ; Tue, 9 Sep 2008 07:38:06 -0700 (MST) Received: from Greg-Beavers-monster.local (CPE-76-84-4-101.neb.res.rr.com [76.84.4.101]) (using SSLv3 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bluga.net (Postfix) with ESMTP id 17EE1C0F08A for ; Tue, 9 Sep 2008 07:38:05 -0700 (MST) Message-ID: <48C68A78.1020108@chiaraquartet.net> Date: Tue, 09 Sep 2008 09:38:48 -0500 User-Agent: Thunderbird 2.0.0.6 (Macintosh/20070807) MIME-Version: 1.0 To: PHP Developers Mailing List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV using ClamSMTP Subject: namespace function/static method/class constant conflict resolution From: greg@chiaraquartet.net (Greg Beaver) Hi, These 2 scripts demonstrate the problem: foo.php: bar.php: The logical solution for functions would be to allow something to disambiguate. I would suggest allowing function:: to differentiate between a method and a function: bar_func.php: The solution for constants can be similar: bar_const.php: To implement this technically, we would need to create two new import hashes, one for functions, and one for constants. For this to be technically possible, we would need to ensure this is illegal: Fortunately, it is easy to test, as zend_do_use() could simply check the other hashes for existence of the name in question. Then, the implementation of unqualified name resolution would consist of doing resolution like so: resolving name::foo(): 1) is there a use blah::name; or use something::else as name;? => resolve "name::foo()" as class blah::name/something::else, method foo 2) is there a class in the current namespace called "name"? => resolve "name::foo()" as class name method foo 3) is there a namespace in the current namespace called "name" and a function in it called "foo"? => resolve to namespace function "name::foo()" 4) resolve name::foo() at runtime using current resolution rules resolving foo(); 1) is there a use function name::foo; or use function something::else as foo;? => resolve "foo()" as namespace function "name::foo()/something::else()" 2) is there a foo() function in the current namespace? => resolve "foo()" as namespace function in the current namespace "foo()" if we are in a namespace: 3a) is there an internal function named foo()? => resolve "foo()" as internal function foo. and if we're in the top-level unnamespace: 3b) is there any global function named foo()? => resolve "foo()" as global function foo. resolving foo [in const context such as "$a = foo;"]: 1) is there a use const name::foo; or use const something::else as foo;? => resolve "foo" as namespace constant name::foo/something::else at compile time 2) is there a const in the current namespace "foo"? => resolve "foo" as namespace constant in current namespace at compile time 3) resolve "foo" as define()d at runtime It must be noted that because functions/constants cannot be autoloaded, we can safely assume that if a namespace function or constant does not exist at runtime, then we can error out immediately. This simplifies resolution slightly over class resolution. If this looks good, I may be able to try my hand at a patch, but I only have time today or tomorrow to do so. Greg