Martin Scotta
On Tue, Jun 7, 2011 at 10:43 AM, John Crenshaw <johncrens...@priacta.com>wrote: > > $apos = curry strpos(..., 'a')); > > $apos(); // runtime error wrong param count? > > $apos("bar"); // fine > > $apos("bar", "foo"); // 'a' casted to long, used as offset? > > $apos("bar", "foo", 0); // run-time error wrong param count? > > 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 > > 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). > > 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. > > 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. > > Hey Jhon, What about writing your curry idea in plain PHP, as a proof of concept. Then you can show examples live and others can toy with it. I'm pretty sure most php developers are not used to curry -- or at least those who don't have functional programming skills > John Crenshaw > Priacta, Inc. >