Re: function call chaining

From: Date: Tue, 19 Jan 2010 17:03:21 +0000
Subject: Re: function call chaining
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-46810@lists.php.net to get a copy of this message
Hello, On Mon, Jan 18, 2010 at 5:27 PM, Stanislav Malyshev <stas@zend.com> wrote: > I wrote a small patch that enables this kind of syntax in PHP: > > foo()(); > ... I think language enhancements with no BC breaks that offer a wider toolset to programmers is a good thing. I would also like to see the other ideas in this thread implemented such as array access & object creation. The only thing I do not like about this is I do not beleive it fits the PHP error model. Lets just say Bar::foo($arg) returns a function callback or FALSE/NULL on a error condition. So you end up with a function call to something that is not callable, the PHP way under this case is to have a fatal error. I would rather not see more ways to cause fatal errors in PHP (call to undefined method has gotten a bit more popular since object chaining has risen in popularity as well). Of course I know exceptions are likely out of the question for these kinds of cases as well. These thoughts do not apply to array access or object creation. Regards, -Chris

« previous php.internals (#46810) next »