From: mame@... Date: 2019-11-10T10:39:34+00:00 Subject: [ruby-core:95774] [Ruby master Feature#16253] Shorthand "forward everything" syntax Issue #16253 has been updated by mame (Yusuke Endoh). Eregon (Benoit Daloze) wrote: > Note: this feature allows `def m(...)` but not `def m(meth, ...)` on current Ruby master. > > I found that in some cases, the behavior is rather surprising as `...` can also be the beginless endless Range: > ``` > $ ruby -e 'def m(...); p(...); end; m(1,2)' > 1 > 2 > > $ ruby -e 'def m(...); p ...; end; m(1,2)' > > ^ nothing > > $ ruby -e 'def m(...); p ...; end; p m(1,2)' > nil...nil > > $ ruby -e 'def m(...); p(...[0]); end; m(1,2)' > ...[0] > ``` > > Can someone explain the second one? It is parsed as an endless range `((p)...)`. ---------------------------------------- Feature #16253: Shorthand "forward everything" syntax https://bugs.ruby-lang.org/issues/16253#change-82593 * Author: Dan0042 (Daniel DeLorme) * Status: Closed * 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>