2010-01-19 17:05, Stanislav Malyshev skrev:
I honestly don't see func()()()() make anything better in the
world of a PHP programmer.

You probably don't use closures, right?

Sorry for kidnapping a thread, bit it was this message that got me thinking about raising the issue in earnest.

I'm also a little late to the party, replying to amonth old message, since I do not have time to read this list as often as I'd like.

My question is not so much about implementation it is about language. I have noticed quite a few times now that PHP developers use the word "closure" when I would prefer "lambda".

In discussions about JavaScript (where I have spent most of my time the last couple of years) the word "closure" is never used outside the context of inherited scope, AFAIK.

A few examples:

<blockquote cite="http://www.javascriptkit.com/javatutors/closures.shtml";>
Two one sentence summaries:
* a closure is the local variables for a function - kept alive after the function has returned, or * a closure is a stack-frame which is not deallocated when the function returns. (as if a 'stack-frame' were malloc'ed instead of being on the stack!)
<blockquote>

<blockquote cite="http://www.webreference.com/programming/javascript/rg36/";>
A closure takes place when a function creates an environment that binds local variables to it in such a way that they are kept alive after the function has returned. A closure is a special kind of object that combines two things: a function, and any local variables that were in-scope at the time that the closure was created.
</blockquote>

In my line of work I have read about 10 books on JavaScript the last couple of years, including the works of all big names like D. Crockford, John Resig, Nicholas Zakas, etc. They all describe closures in this fashion.

However, in the PHP manual as well as on this list, you seem to be saying "closure" === "anonymous function" (which is what I'd rather see called lambda).

This difference in the use of words is a bit confusing I would say. One may also note that in JavaScript closures exists even with named functions, i.e. it does not need to be anonymous.

Maybe this discussion belongs on the documentation list, but I wanted the reach the core developers, since you are the guys (and gals) that have produced the features and set the language.

If I am out of line, please let me know and I will take my questions elsewhere.

Oh, yes, the question:

Wouldn't you agree that it is better for PHP to use the word closure as it is being used in the JavaScript community?


--
Keryx Web (Lars Gunther)
http://keryx.se/
http://twitter.com/itpastorn/
http://itpastorn.blogspot.com/

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

Reply via email to