From: "mame (Yusuke Endoh)" Date: 2012-04-03T00:18:24+09:00 Subject: [ruby-core:44072] [ruby-trunk - Feature #4610][Rejected] Proc#curry behavior is inconsistent with lambdas containing default argument values Issue #4610 has been updated by mame (Yusuke Endoh). Status changed from Assigned to Rejected Hello, I don't think it is a good idea to solve the original problem by using Proc#curry. And I like the current behavior of Proc#curry. It is simple and straightforward. jballanc (Joshua Ballanco) wrote: > proc {|x, y, z, *rest| puts "#{x}, #{y}, #{z}, #{rest.join(',')}" > }.curry.(1).(2).(3).(4) > # => "1, 2, 3, 4" It will require an extra call for invoking the proc when we want to supply no argument to the rest: proc {|x, y, z, *rest| puts "#{x}, #{y}, #{z}, #{rest.join(',')}" }.curry.(1).(2).(3).() # => "1, 2, 3, " Anyway, keyword argument is implemented in trunk now. Please give it a try first. After that, if you still think you need anything, please reopen this ticket with clear statement about what you need. Thanks, -- Yusuke Endoh ---------------------------------------- Feature #4610: Proc#curry behavior is inconsistent with lambdas containing default argument values https://bugs.ruby-lang.org/issues/4610#change-25606 Author: jballanc (Joshua Ballanco) Status: Rejected Priority: Normal Assignee: mame (Yusuke Endoh) Category: Target version: If I curry a lambda with 3 arguments, then I can call three times with one argument each time to get the desired results: ruby-1.9.2-p180 :001 > l = ->(a, b, c) { puts "#{a}, #{b}, #{c}" } # ruby-1.9.2-p180 :002 > c = l.curry # ruby-1.9.2-p180 :003 > c.('one').('two').('three') one, two, three nil However, if the lambda has default values and I curry it, the entire lambda is evaluated after the first #call: ruby-1.9.2-p180 :004 > l = ->(a = 'ichi', b = 'ni', c = 'san') { puts "#{a}, #{b}, #{c}" } # ruby-1.9.2-p180 :005 > c = l.curry # ruby-1.9.2-p180 :006 > c.('one').('two').('three') one, ni, san NoMethodError: undefined method `call' for nil:NilClass This behavior seem very inconsistent. Ideally, if I wanted to use the default argument at a certain position in a currie proc, I would just #call with no arguments, like so: ruby-1.9.2-p180 :007 > c.('one').().('three') #=> Propose that this result in: "one, ni, three" -- http://bugs.ruby-lang.org/