Re: Re: Namespaced function vs static method in global class
| From: | Ionut Gabriel Stan | Date: | Thu, 18 Sep 2008 19:42:42 +0000 |
| Subject: | Re: Re: Namespaced function vs static method in global class | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-40557@lists.php.net to get a copy of this message | ||
Thanks for your answer guys, they answered my questions. Hopefully any introduction in the language
of a __getStatic() and __setStatic() won't make things even more confusing.
Thanks also for the effort you put in developing PHP, I really appreciate it.
Cheers,
I. Stan
----- Original Message ----
From: Gregory Beaver <greg@chiaraquartet.net>
To: Ionut Gabriel Stan <ionut.stan@yahoo.com>
Cc: internals@lists.php.net
Sent: Wednesday, September 17, 2008 7:25:31 AM
Subject: [PHP-DEV] Re: Namespaced function vs static method in global class
Ionut Gabriel Stan wrote:
<snip>
> echo Test::foo(); // outputs namespace function
> echo '<br>';
> echo ::Test::foo(); // outputs namespace function
<snip>
> 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
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php