rfc:currying
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:currying [2011/06/05 23:35] – added PEP lstrojny | rfc:currying [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Request for Comments: Currying ====== | ====== Request for Comments: Currying ====== | ||
- | * Version: 0.9 | + | * Version: 0.9.1 |
* Date: 2011-06-11 | * Date: 2011-06-11 | ||
* Author: Lars Strojny < | * Author: Lars Strojny < | ||
Line 94: | Line 94: | ||
$func(" | $func(" | ||
</ | </ | ||
+ | |||
+ | === Implementation details === | ||
+ | Keyword '' | ||
+ | |||
+ | <code php> | ||
+ | $func = curry strpos(..., " | ||
+ | </ | ||
+ | |||
+ | Would result in this code: | ||
+ | <code php> | ||
+ | $func = function($arg1) { | ||
+ | return strpos($arg1, | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | Another example with a variable function name: | ||
+ | |||
+ | <code php> | ||
+ | $funcName = " | ||
+ | $func = curry $funcName(..., | ||
+ | </ | ||
+ | |||
+ | This would result in: | ||
+ | <code php> | ||
+ | $funcName = " | ||
+ | $func = function($arg1) use ($funcName) { | ||
+ | return $funcName($arg1, | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | Example with variable arguments: | ||
+ | <code php> | ||
+ | $char = " | ||
+ | $func = curry strpos(..., $char); | ||
+ | </ | ||
+ | |||
+ | <code php> | ||
+ | $char = " | ||
+ | $func = function($arg1) use ($char) { | ||
+ | return strpos($arg1, | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | === Pitfalls and criticism === | ||
+ | == Performance == | ||
+ | How is performance affected because of the heavy use of Closure objects? I don’t know yet, any guesses? | ||
+ | |||
+ | == Error Handling == | ||
+ | Error messages could be misleading. E.g. not passing an argument to '' | ||
+ | |||
+ | * Bad error message: '' | ||
+ | * Better error message: '' | ||
+ | |||
+ | Error handling for curried functions should be a little more strict in terms of "too many parameters" | ||
==== Notes ==== | ==== Notes ==== | ||
- | * Keyword '' | ||
* I could use some helping hand with the parser work, if you are interested, drop me a message | * I could use some helping hand with the parser work, if you are interested, drop me a message | ||
==== References ==== | ==== References ==== | ||
- | | + | * Wikipedia: http:// |
- | - PEP-0309: http:// | + | |
===== Changelog ===== | ===== Changelog ===== | ||
- | * Initial draft | + | * 0.9: Initial draft |
+ | * 0.9.1: RFC changed based on feedback from php-internals and #pecl.php | ||
+ | * Removed alias '' | ||
+ | * Discussing implementation details and error handling | ||
rfc/currying.1307316937.txt.gz · Last modified: 2017/09/22 13:28 (external edit)