Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision |
rfc:currying [2011/06/07 11:46] – 0.9.1 lstrojny | rfc:currying [2017/09/22 13:28] (current) – external edit 127.0.0.1 |
---|
</code> | </code> |
| |
There are a few concerns to implement it that way: | === Pitfalls and criticism === |
* How is performance affected because of the heavy use of Closure objects? I don’t know yet, any guesses? | == Performance == |
* Error messages could be misleading. E.g. not passing an argument to ''$func()'' would result in a warning for a missing argument when calling ''$func()'' without any mention of ''strpos()''. One way to overcome this problem would be to have ''class CurriedFunction extends Closure''. This subclass would contain additional properties for a nicer the error message. It would even be possible to override error handling for ''CurriedFunction::__invoke()'' to make it more specific. | How is performance affected because of the heavy use of Closure objects? I don’t know yet, any guesses? |
* Bad error message: ''Missing argument 1 for {closure}(), called in <file> on line <line> and defined in <file> on line <line>'' | |
* Better error message: ''Missing argument 1 for curried strpos(..., "f"), called in <file> on line <line> and defined in <file> on line <line>'' | == Error Handling == |
| Error messages could be misleading. E.g. not passing an argument to ''$func()'' would result in a warning for a missing argument when calling ''$func()'' without any mention of ''strpos()''. One way to overcome this problem would be to have ''class CurriedFunction extends Closure''. This subclass would contain additional properties for a nicer the error message. It would even be possible to override error handling for ''CurriedFunction::__invoke()'' to make it more specific. |
| |
| * Bad error message: ''Missing argument 1 for {closure}(), called in <file> on line <line> and defined in <file> on line <line>'' |
| * Better error message: ''Missing argument 1 for curried strpos(..., "f"), called in <file> on line <line> and defined in <file> on line <line>'' |
| |
| Error handling for curried functions should be a little more strict in terms of "too many parameters". If somebody passed more parameters than defined in the curry statement, a warning should be thrown stating, that the additional parameters are ignored. |
| |
==== Notes ==== | ==== Notes ==== |