Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:40537 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26440 invoked from network); 17 Sep 2008 04:24:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Sep 2008 04:24:43 -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:51270] helo=mail.bluga.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 97/E0-30574-A8680D84 for ; Wed, 17 Sep 2008 00:24:42 -0400 Received: from mail.bluga.net (localhost.localdomain [127.0.0.1]) by mail.bluga.net (Postfix) with ESMTP id 125C9C0E557; Tue, 16 Sep 2008 21:23:47 -0700 (MST) Received: from [192.168.0.106] (unknown [76.84.4.101]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bluga.net (Postfix) with ESMTP id 9A2BAC0E555; Tue, 16 Sep 2008 21:23:46 -0700 (MST) Message-ID: <48D086BB.2050303@chiaraquartet.net> Date: Tue, 16 Sep 2008 23:25:31 -0500 User-Agent: Thunderbird 2.0.0.16 (X11/20080724) MIME-Version: 1.0 To: Ionut Gabriel Stan CC: internals@lists.php.net References: <46322.71759.qm@web36401.mail.mud.yahoo.com> In-Reply-To: <46322.71759.qm@web36401.mail.mud.yahoo.com> X-Enigmail-Version: 0.95.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV using ClamSMTP Subject: Re: Namespaced function vs static method in global class From: greg@chiaraquartet.net (Gregory Beaver) Ionut Gabriel Stan wrote: > echo Test::foo(); // outputs namespace function > echo '
'; > echo ::Test::foo(); // outputs namespace function > My questions are: > > 1. How should I call the static method foo in the global class Test (except for call_user_func) > 2. How should I call the static method baz of class Bar in namespace Test with call_user_func > 3. Is there no possibility to change your minds and replace the double colon with something else, likes a simple colon? I find it very confusing to figure out what is what and the way I should call it. Hi Ionut, Stas did a good job of answering how to call the static method using call_user_func. The answer to #1 under the current implementation is "you can't" which is why I posted a patch to allow differentiating between the two earlier this week. However, I have since discovered a much better solution, and have a working patch, but am checking details offlist before I propose it, as it involves a slight but important change to namespace syntax. Stay tuned for further details. As for your 3rd question, I guarantee this will not happen, as it is technically impossible to do. For instance: switch ($something) { case oops: is:this:part:of:oops(); break; } The above code could resolve to either "case oops:" followed by "is:this:part:of:oops()" or as "case oops:is:this:part:of:oops()" and there is no way for a computer to tell the difference without introducing required whitespace. Since PHP != Python, that won't happen :). Greg