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=-2.8 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=no 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 B06D21F454 for ; Sun, 10 Nov 2019 10:27:51 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 715261209B5; Sun, 10 Nov 2019 19:27:41 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 67DD112099F for ; Sun, 10 Nov 2019 19:27:38 +0900 (JST) Received: by filter0089p3las1.sendgrid.net with SMTP id filter0089p3las1-25463-5DC7E620-4 2019-11-10 10:27:44.165903212 +0000 UTC m=+219069.662084410 Received: from herokuapp.com (unknown [3.92.225.197]) by ismtpd0035p1mdw1.sendgrid.net (SG) with ESMTP id BsthGdKbTn2Dx7j4C0CLmA for ; Sun, 10 Nov 2019 10:27:43.969 +0000 (UTC) Date: Sun, 10 Nov 2019 10:27:44 +0000 (UTC) From: eregontp@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 71398 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 16253 X-Redmine-Issue-Author: Dan0042 X-Redmine-Sender: Eregon 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?KippOI8ZHtTweq7XfQzW93937kJ4QNWwSBuHnaMEcr0opxp0KXp=2FnWdWlm2slX?= =?us-ascii?Q?OZ5PxK9nO35g7G5O52XlVjSlZ2lYino0arNIu6p?= =?us-ascii?Q?NNxqPwUZ6L1RAiB7Zj+01NGtLHVtP1XnsJ3OU2q?= =?us-ascii?Q?3QJU5G2AmqU+zxIFyrxko=2FfRnTYu5roEzQEMKDc?= =?us-ascii?Q?r8dOMqbluRjhJI9KtGtHtuLfN6gU5n+UOqA=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95773 Subject: [ruby-core:95773] [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 Eregon (Benoit Daloze). 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? I think we should clarify for this feature that `...` isn't an object or an expression, it's only valid as arguments passed to a method. ---------------------------------------- Feature #16253: Shorthand "forward everything" syntax https://bugs.ruby-lang.org/issues/16253#change-82592 * 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/