rfc:iteration-tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
rfc:iteration-tools [2008/11/03 14:43] – refining some ideas amenthesrfc:iteration-tools [2008/11/03 15:03] amenthes
Line 1: Line 1:
 ====== Request for Comments: Iteration tools in PHP ====== ====== Request for Comments: Iteration tools in PHP ======
   * Version: 1.0   * Version: 1.0
-  * Date: 2008-10-29+  * Date: 2008-11-03
   * Author: Ionut Gabriel Stan <ionut.dot.g.dot.stan.at.gmail.com>   * Author: Ionut Gabriel Stan <ionut.dot.g.dot.stan.at.gmail.com>
-  * Status: RFC not yet completed+  * Status: In the works
   * First Published at: http://wiki.php.net/rfc/iteration-tools   * First Published at: http://wiki.php.net/rfc/iteration-tools
  
Line 34: Line 34:
  
 The list may go on with a few other abstracted use cases. The list may go on with a few other abstracted use cases.
 +
 It turns out that separating the iteration from the inner data calculations is a good thing and people came up with some higher order functions, that took at least two parameters, the data set to be processed and the *function* that did the processing (which in some of the cases were "unnamed" functions or lambdas). Languages that did not have possibilities for higher order functions made use of their best features and provided different alternatives if any. For example in PHP we have at our disposal the following SPL classes revolving around the same idea: It turns out that separating the iteration from the inner data calculations is a good thing and people came up with some higher order functions, that took at least two parameters, the data set to be processed and the *function* that did the processing (which in some of the cases were "unnamed" functions or lambdas). Languages that did not have possibilities for higher order functions made use of their best features and provided different alternatives if any. For example in PHP we have at our disposal the following SPL classes revolving around the same idea:
     * FilterIterator     * FilterIterator
Line 108: Line 109:
  
 Although the above tools were listed as functions, as they don't do that much, they might just as well be class constructors (honestly I don't like this approach). I thought functions could do just fine because of the new namespace support that's why I represented them as such. Although the above tools were listed as functions, as they don't do that much, they might just as well be class constructors (honestly I don't like this approach). I thought functions could do just fine because of the new namespace support that's why I represented them as such.
 +
 Additionally, one thing I haven't represented in the above signatures is that an additional argument may be passed to the callback function representing an iteration counter. Additionally, one thing I haven't represented in the above signatures is that an additional argument may be passed to the callback function representing an iteration counter.
  
Line 191: Line 193:
     * http://www.python.org/doc/2.5.2/tut/node7.html#SECTION007130000000000000000     * http://www.python.org/doc/2.5.2/tut/node7.html#SECTION007130000000000000000
     * http://www.python.org/doc/2.5.2/lib/itertools-functions.html (these Python package differs quite much from what I have proposed, nevertheles we may extract other useful things from there too)     * http://www.python.org/doc/2.5.2/lib/itertools-functions.html (these Python package differs quite much from what I have proposed, nevertheles we may extract other useful things from there too)
- 
- 
-===== Changelog ===== 
- 
- 
- 
  
rfc/iteration-tools.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1