[ruby-core:96020] [Ruby master Feature#16378] Support leading arguments together with ...

[email protected]
Newsgroups gmane.comp.lang.ruby.core
Message-ID <redmine.journal-82862.20191128103043.62f104a0d653f70d@ruby-lang.org>
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:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.