Re: Implementation help needed: Currying RFC
Hi John,
thanks for your feedback.
Am 07.06.11 15:43 schrieb "John Crenshaw" unter <[email protected]>:
[...]
>I understand where this can be useful sometimes, but I disagree that this
>should be added as a language feature. It is still possible to implement
>this (parameter positioning in your curried function) using a function
>that returns a closure similar to the curry_left example in the RFC. One
>possible method (inspired by the C++ system for doing the same thing)
>would be:
>
>$apos = curry( 'strpos', _1(), 'a' ); // _1() returns a placeholder
>positioning object
Interesting idea to use placeholder argument as it is implementable in
user space (or as a PECL extension or a bundled one) without touching the
parser. Maybe an arg()-Function which returns a placeholder object would
be the way to go. Something like this maybe:
$apos = curry('strpos, arg(1), 'a);
>This isn't quite as nice as the proposed T_FILL, but on the other hand,
>it is more powerful (parameters could change order) and isn't nearly as
>confusing as the RFC syntax (which looks like perhaps strpos is being
>called in some strange way).
Could you elaborate on how parameters could change order?
>Of course, there is also always the regular old closure, which is far
>more explicit and leaves no confusion about exactly what is being
>returned.
That¹s true. The main motivation for this proposal is brevity and less
boilerplate code for callbacks.
>No offense to anyone who loves currying, but I don't see why this should
>be implemented. There are plenty of good options available for achieving
>identical or better results without modifying the language.
Thanks again for your opinion and the idea of having an argument
placeholder.
With regards,
Lars
Thread (10 messages)