New 2.7/3.0 keyword argument pain point

We’re currently fixing all the 2.7 warnings in Shopify’s monolith, and there’s indeed a lot of them.

Overall my opinion is that new keywords argument are definitely better than the old ones.

However I’ll be echoing out what the other said, the main pain point is blind delegation. In some cases the new ... helps (actually we can’t use it just now because Sorbet can’t parse it yet), but it has many annoying limitations:

  • Can’t use it if you delegate with public_send/send.
  • Can’t use it if you want to extract one of the arguments (typical for method_missing)
  • Can’t use it if you want to add one argument.
  • Can’t use it in block parameters (typical for define_method)

I think removing the current limitations to ... would help a lot.

However that’s only true for your own application code. As soon as you are writing code in a gem that is expected to support older Rubies, it won’t help you.

I suppose that’s what ruby2_keywords is for, but it’s tedious to use. A magic comment like frozen_string_literal would have been preferable, but now that 2.7.0 and 2.7.1 are released, it will be complicate to support them.

6 Likes