Issue #16378 has been updated by Eregon (Benoit Daloze).


matz (Yukihiro Matsumoto) wrote:
> I know trailing `...` can be very useful from C experience. But the primary purpose of Ruby `...` is method delegation. We are not going to extend the role of `...` in the language (at least for now).

That is surprising.
It makes `...` unusable in many delegation use cases which need to extract the first(s) arguments.
The above method_missing is also delegation, isn't it?

What's your solution for that case?
Using `ruby2_keywords def method_missing(name, *args)` and then having to change it to `def method_missing(name, *args, **kwargs)` once `ruby2_keywords` is removed?
Defining `method_missing` is not something rare in Ruby. It seems a shame `...` can't be used there, even though it would a very good place to use `...` (delegation in `method_missing` is almost always lexical).

BTW, `R` has `...` and it supports leading arguments.
And of course the construct that `...` replaces, that is `*args, &block` as "all arguments" supports leading arguments too.

----------------------------------------
Feature #16378: Support leading arguments together with ...
https://bugs.ruby-lang.org/issues/16378#change-82862

* Author: Eregon (Benoit Daloze)
* Status: Rejected
* Priority: Normal
* Assignee: 
* Target version: 2.7
----------------------------------------
I think this is very important, otherwise `...` can be used only very rarely.

For instance, `method_missing` typically want to access the method name like:
```ruby
def method_missing(name, ...)
  if name.to_s.end_with?('?')
    self[name]
  else
    fallback(name, ...)
  end
end
```

See the original feature: https://bugs.ruby-lang.org/issues/16253#note-19.
I think most people expect `def method_missing(name, ...)` to work.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>