Re: Return type hinting patch
| From: | David Zülke | Date: | Sun, 27 Apr 2008 00:20:48 +0000 |
| Subject: | Re: Return type hinting patch | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-37257@lists.php.net to get a copy of this message | ||
But anonymous functions and lambda expressions are not the same thing...
David
Am 27.04.2008 um 02:11 schrieb Chris Stockton:
*cough* lambda *cough* On Sat, Apr 26, 2008 at 4:26 PM, David Zülke <dz@bitxtender.com> wrote: Am 27.04.2008 um 00:24 schrieb Nathan Nobbe: On Sat, Apr 26, 2008 at 2:06 PM, David Zülke <dz@bitxtender.com> wrote: Wouldn't the most consistent way be to omit "function" altogether when using a return type hint? public static function zomg() { return $somethingArbitrary; } public static string foo() { return $mustBeString; } i think leaving 'function' in there makes sense because thats the way php currently works. Well that was my point. Functions without return type hints use "function", to indicate that they are generic in this respect, and functions/methods with a type hint omit it to signal the difference. Having both would be redundant. But then...: otoh, should there ever be a type "function" (e.g. for anonymous funcs) down the road, that'd mean trouble ;) wow; good point! maybe if anonymous functions are ever supported the type could be capitalized as in 'Function' public function Function doStuff() { return function() {} } Absolutely not. Right now, all PHP native types are lowercase. Can't see why anon functions should be different. Actually, both ways have problems: public function gimmeThat() { return function() { echo 'yay'; } } is ambiguous if return type hints require omitting "function", and public function function gimmeThat() { ... } is just plain ugly. So maybe anon funcs should have a different type name :p David --PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php