From: "jeremyevans0 (Jeremy Evans)" Date: 2021-12-09T15:38:19+00:00 Subject: [ruby-core:106601] [Ruby master Feature#18351] Support anonymous rest and keyword rest argument forwarding Issue #18351 has been updated by jeremyevans0 (Jeremy Evans). mame (Yusuke Endoh) wrote in #note-3: > The concern about `Method#parameters` should be discussed after Ruby 3.1 is released. Now `Method#parameters` of `def foo(...)` returns `[[:rest, :*], [:keyrest, :**], [:block, :&]]`. After this change, perhaps it would be unable to distinguish between `def foo(...)` and `def foo(*, **, &)`. But, I have no idea whether we should be able to distinguish them. I don't think there is a need to distinguish them. In both the `foo(...)` and `def foo(*, **, &)` cases, the method accepts the same parameters (all normal parameters, all keyword parameters, and a block). You have no idea what the method is doing with the arguments. In both cases, the method can ignore the arguments, or delegate them. `foo(*, **, &)` is more flexible in that it can delegate the arguments separately, which `foo(...)` cannot do, but that's an implementation detail of the method, not what arguments it accepts (which is what Method#parameters returns). It is possible to choose different names for the `*` and `**` anonymous parameters, and recognize those names and keep Method#parameters output the same as it currently is, but I think the behavior in the current PR is better. Can anyone show a problem with having Method#parameters for `foo(...)` and `def foo(*, **, &)` return the same result? ---------------------------------------- Feature #18351: Support anonymous rest and keyword rest argument forwarding https://bugs.ruby-lang.org/issues/18351#change-95268 * Author: jeremyevans0 (Jeremy Evans) * Status: Open * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) ---------------------------------------- I would like to add support for the following syntax: ```ruby def foo(*) bar(*) end def baz(**) quux(**) end ``` This is a natural addition after the introduction of anonymous block forwarding. Anonymous rest and keyword rest arguments were already supported in method parameters, this just allows them to be used as arguments to other methods. The same advantages of anonymous block forwarding apply to rest and keyword rest argument forwarding. I've submitted a pull request implementing this syntax: https://github.com/ruby/ruby/pull/5148 -- https://bugs.ruby-lang.org/ Unsubscribe: