Issue #16253 has been updated by Dan0042 (Daniel DeLorme).


> * Is `*` or `...` an expression? What does `def m(...); a = ...; p a; end; m(1, a: 2) {}` print?

I would tend to say `a = ...` is a syntax error; my intention was to use this only in the argument list of a method call, with an implementation similar to `super` without parentheses.

> * Do we want to support required arguments before? It would be useful for `method_missing`

Then rather than "forward everything" the meaning would be more like "capture all extra arguments". That means we could have `foo(a, *)` or `foo(a, k:, *)` or `foo(a, k:, *, &b)` ... imho this is too complicated and it's better to just use the regular syntax at that point.

But it's true that often we want to operate on the arguments before forwarding, so I think maybe an asymmetric syntax like this would work best?

```ruby
def method_missing(name, *) #currently valid syntax
  if name.to_s.end_with?('!')
    super
  else
    @target.send(***) #forward everything, including name
  end
end
```

----------------------------------------
Feature #16253: Shorthand "forward everything" syntax
https://bugs.ruby-lang.org/issues/16253#change-82074

* Author: Dan0042 (Daniel DeLorme)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
What about using this:

```ruby
  def foo(*)
    @bar.foo(*)
```

to mean this:

```ruby
  def foo(*a, **o, &b)
    @bar.foo(*a, **o, &b)
```

I used `def foo(*)` because that's currently valid ruby code, but I'm fine with any syntax.

It's like the no-parentheses `super` shorthand, but for any method.

It makes it easier to write correct forwarding code. 

If rubyists must be told they have to change their forwarding code in 2.7 (due to keyword arguments), the pill might be easier to swallow if the change is a reduction rather than an increase in verbosity.

And we'd even be future-proof if an eventual FOURTH kind of parameter is introduced!!!!




-- 
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>