|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-06-30 15:54 UTC] 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 --- PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 16 11:00:01 2025 UTC |
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.