From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-4.1 required=3.0 tests=AWL,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 42A701F454 for ; Sun, 10 Nov 2019 10:39:45 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id D0F111209D2; Sun, 10 Nov 2019 19:39:33 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id 45E6412098A for ; Sun, 10 Nov 2019 19:39:30 +0900 (JST) Received: by filter0100p3las1.sendgrid.net with SMTP id filter0100p3las1-5139-5DC7E8E6-E 2019-11-10 10:39:34.235431911 +0000 UTC m=+219182.631904085 Received: from herokuapp.com (unknown [3.92.225.197]) by ismtpd0081p1mdw1.sendgrid.net (SG) with ESMTP id FeimhOo8Q7Gz1ogY3Mfpqg for ; Sun, 10 Nov 2019 10:39:33.967 +0000 (UTC) Date: Sun, 10 Nov 2019 10:39:34 +0000 (UTC) From: mame@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 71399 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 16253 X-Redmine-Issue-Author: Dan0042 X-Redmine-Sender: mame X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?EJh2gqwnyqXtd++xo=2FinyA1V0bXouTB4FkWnzNiKb4=2FPqAyPfDqG+3Cnmp6vWw?= =?us-ascii?Q?MakF6mUxZQ3LUR=2F+eUp42jjAz8BK6pO4O10VGt1?= =?us-ascii?Q?yX1CyVW3UwlZGW2UMJZ0ECsd2Zdav+q4imYhDk8?= =?us-ascii?Q?h1K76kY+=2FDjuJqenSoThWWHikrQHtaF8NVg0fTs?= =?us-ascii?Q?mm8Am9A6VGLD5cw1n0J3vW=2FdfOfjcXmS4eg=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95774 Subject: [ruby-core:95774] [Ruby master Feature#16253] Shorthand "forward everything" syntax X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" 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/