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


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to