Hi, I was reading Damian's new excellent diary entry in which he explains the new currying syntax for Perl6.
(For the lazy ones it's reachable at http://www.yetanother.org/damian/diary_latest.html) This new feature allows to partially fill place-holder functions, such as: my &div = {$^x / $^y}; my &half= &div(y=>2}; print half(6); # 3 This is a very neat feature, and very useful, as it's explained very well on Damian's page. But I am not sure I like the syntax. The problems I see are: - You only can curry placeholder-generated functions. So if you intend to make a function curryiable, you are forced to use place-holders, even if that's not the cleanest way of programming it. - This means that the creator of a function needs to impose a policy on whether he expects the function users to use currying or not. A module creator and user could have different point of views about it, creating unnecessary conflict between the human race. - From the caller point of view, the only distinction between a function call and a currying pseudo-call, is the number of parameters. div(6,3) # is a function call div(6) # creates a new curryied function So, in order to see if a expression is a function call or a magic currying, you need to count (!) the number of parameters, without any visual clue suggesting it. - You cannot use advanced perl 6 features (like optional strict typing, or default values for function parameters), on curryiable functions. I would instead propose that every function object supports a "curry" method, that performs such operation. For example: sub div($x,$y) {$x / $y}; # of &div = {$^x / $^y} my &half = &div.curry(y=>2); print half(6); # 3 This solves the unnecessary placeholder-currying marriage, and it is certainly a more explicit syntax. Incidentally, a newbie user would learn that there is a curry method being called, and could google "curry perl" and even find some useful docs. (In my humble opinion, this is something that is too many times forgotten in the perl world. With the ultra-compact, idiomatic syntax, it is __very__ hard to learn perl the google way). What do you think about it? -angel
