From: Guoliang Cao Date: 2008-04-27T13:16:25+09:00 Subject: Re: PartialInvocation sample Trans wrote: > > Hi, > > #_ is sort off limits because IRB uses it. However, #__ is usable, and > that is what Facets' library uses. I'm not familiar with how _ is used in IRB. Can you please explain a bit more? > > While the notation is nice, I'm not sure is necessary. If #curry is > extended to take slot-order as arguments, then curry itself can be > used. Eg. > > aproc = Proc.new{ |a,b| a ** b } > > aproc.curry => lambda{ |a| lambda{ |b| a ** b }} > > aproc.curry(1) => lambda{ |b| lambda{ |a| a ** b }} > > More complex... > > aproc = Proc.new{ |a,b,c,d| ...} > > aproc.curry(3,1,0) => lambda{ |d| lambda{ |b| lambda{ |a| lambda{ | > c|... > > Note, that last slot (2) is implied and need not be specified in the > arguments. > > T. I agree curry can be made more generic. It'll be even better if we can have partial invocation on method calls. I think most of the time procs are local to a method and we can substitute known values into proc body without currying. However partial method invocation can be very useful to reduce entering same literal values. -- Posted via http://www.ruby-forum.com/.