Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53201 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37053 invoked from network); 8 Jun 2011 10:29:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Jun 2011 10:29:08 -0000 Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 217.114.211.66 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 217.114.211.66 ns.km36107.keymachine.de Received: from [217.114.211.66] ([217.114.211.66:63555] helo=config.schlueters.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DA/5E-50253-1FE4FED4 for ; Wed, 08 Jun 2011 06:29:06 -0400 Received: from [192.168.2.230] (ppp-93-104-60-7.dynamic.mnet-online.de [93.104.60.7]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by config.schlueters.de (Postfix) with ESMTPSA id 06AF572672; Wed, 8 Jun 2011 12:29:00 +0200 (CEST) To: Hannes Magnusson Cc: Stas Malyshev , Matthew Weier O'Phinney , internals@lists.php.net In-Reply-To: References: <4DED3D5B.6030307@oracle.com> <4DEE782E.1020605@sugarcrm.com> <1307489981.23373.31.camel@guybrush> <1307527464.3635.395.camel@guybrush> Content-Type: text/plain; charset="UTF-8" Date: Wed, 08 Jun 2011 12:29:00 +0200 Message-ID: <1307528940.3635.479.camel@guybrush> Mime-Version: 1.0 X-Mailer: Evolution 2.30.2 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Callable type From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) On Wed, 2011-06-08 at 12:17 +0200, Hannes Magnusson wrote: > >> A callable wouldn't be fully featured type. > > > > Which means that > > class callable { } > > No. 'callable' is a parser token. Which has larger implications. This break code where people use callable as constant, property, function or method name. This seems to hit symfony and a few others. http://google.com/codesearch?hl=en&lr=&q=lang%3Aphp+%22-%3Ecallable% 22&sbtn=Search (yes breaking stuff can be fine, but we should at least be aware of it ;-) ) > > Ok. I assume NULL as default value would be allowed, though. This would > > be consistent for the language and allow such things: > > > > function foo(callback $cb = NULL) { > > if (!$cb) { > > $cb = function() { /* .. default implementation */ > > } > > .... > > } > > Etienne pointed out that default values for arrays can actually contain values.. > I actually had no idea. > > I suppose we then need to support default values for an array callable. As I pointed out on IRC I'm not sure that's good, unless we want closures as defaults, too. Which we probably won't like. > But yes, a callable can have the default value of null, following the > rules of class hinting. Good. johannes