Project

General

Profile

Feature #16253

Shorthand "forward everything" syntax

Added by Dan0042 (Daniel DeLorme) 7 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:95338]

Description

What about using this:

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

to mean this:

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


Related issues

Related to Ruby master - Misc #16157: What is the correct and *portable* way to do generic delegation?OpenActions
Related to Ruby master - Feature #16296: Alternative behavior for `...` in method body if `...` is not in method definitionOpenActions
Related to Ruby master - Feature #16378: Support leading arguments together with ...Openmatz (Yukihiro Matsumoto)Actions

Also available in: Atom PDF