Re: Closures
| From: | Shawn McKenzie | Date: | Wed, 19 Mar 2008 03:56:25 +0000 |
| Subject: | Re: Closures | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-271765@lists.php.net to get a copy of this message | ||
Ray Hauge wrote:
> I've been reading up on some of the parts of PHP that has been suggested
> could be improved so that I could be more well informed. One of the
> more "interesting" (for lack of a better word) suggestions is closures.
> I've used closures primarily in JavaScript, and they are handy in that
> context, but JavaScript handles events and other more dynamic situations
> like that.
>
> I can't really think of any good examples of why I'd want to use a
> closure instead of just calling functions or class methods in PHP.
> Variable functions and call_user_func*() have worked for any of the
> cases where I did need to be a bit more dynamic.
>
> I found a great summary of some discussion on the internals mailing list
> over here: http://devzone.zend.com/node/view/id/2013#Heading1
>
> After reading that article through, I do like Wez's idea of how to
> create anonymous functions. The point about it causing confusion with
> people coming from other languages definitely applies though. This
> article also gives me a second idea for this post. How many people
> would want closures in PHP?
>
> In summary:
>
> Would you want closures in PHP, and why?
>
O.K. so I check wikipedia and read what a closure was :-) But what in a
simple sentence or two would is the benefit of a closure compared to how
you would get the same functionality in PHP now?
-Shawn