#48742 [Opn->WFx]: closure vs anonymous functions.
| From: | vrana@php.net | Date: | Mon, 16 Nov 2009 13:15:20 +0000 |
| Subject: | #48742 [Opn->WFx]: closure vs anonymous functions. | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-3189@lists.php.net to get a copy of this message | ||
ID: 48742
Updated by: vrana@php.net
Reported By: teftin at gmail dot com
-Status: Open
+Status: Wont fix
Bug Type: Documentation problem
PHP Version: Irrelevant
New Comment:
As the class is named Closure then changing the documentation would
worsen readability. Look at anonymous functions without "use" as
closures without bound variables.
Previous Comments:
------------------------------------------------------------------------
[2009-08-20 19:27:34] info at liefcoden dot nl
Actually, this is not a documentation problem, it is an error in the
actual naming of the implementation. It would have been better to name
the internal class "Closure" as "Lambda", as this is the "real" name
of
this concept.
Closure is the concept of introducing variables of an outer scope to
the
current scope, and binding them there.
"function ($quantity, $product) use ($tax, &$total) {}"
This would form closure, whilst:
"function ($quantity, $product) {}"
Would not.
------------------------------------------------------------------------
[2009-06-30 15:54:03] teftin at gmail dot com
Description:
------------
documentation states for function.anonymous states:
"Anonymous functions, also known as closures ..."
this sentence might be true in context of (current) php implementation,
but it is not true in general, as not all anonymous functions are
closures, and closures don't have to be connected to anonymous functions
or functions at all.
http://en.wikipedia.org/wiki/Closure_%28computer_science%29
...
The term closure is often mistakenly used to mean anonymous function.
This is probably because most languages implementing anonymous functions
allow them to form closures and programmers are usually introduced to
both concepts at the same time. These are, however, distinct concepts.
Reproduce code:
---------------
---
From manual page: functions.anonymous
---
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48742&edit=1