New 2.7/3.0 keyword argument pain point

Hi Matz,

Thank you for raising that point and for your work on Ruby!

EDIT: @mame has provided a lot of valuable input in my specific case, which could help other library implementors too. Please check out this comment. Thanks a ton for this help!!!

Just some feedback on my current pain point. In the specific case of DSL (like my gem Kiba ETL and its sister gem kiba-common), capturing args to forward them to classes later, at this point I have found a bit painful to be able to capture kwargs indeed. To that day, Ruby 2.7 is only supported in an experimental branch for this project and I must do more work with it:

Maybe I did something wrong, and also this was done in limited time & I could improve things, but to support a wide range of Rubies, I so far had to rely on RUBY_VERSION, and also when instantiating ETL components (forwarding the kwargs and regular args), I wrote such code:

if RUBY_VERSION >= '2.7'
  klass.new(*args, **(kwargs || {}))
else
  # kwargs should be nil
  klass.new(*args)
end

I will work more on this and I believe it can probably be improved without changes in Ruby, but at least this provides a bit of concrete feedback from a DSL library implementor.

I do not have yet a well-formed opinion on what can be done at the level of Ruby! I am perfectly happy with those hacks, if they are good enough for users to use my gem safely and Ruby can keep making progress.

5 Likes