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=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,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 E70CF1F4C0 for ; Fri, 18 Oct 2019 23:17:32 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 2C2A6120B08; Sat, 19 Oct 2019 08:17:23 +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 B7988120AED for ; Sat, 19 Oct 2019 08:17:20 +0900 (JST) Received: by filter0150p3mdw1.sendgrid.net with SMTP id filter0150p3mdw1-14832-5DAA4803-37 2019-10-18 23:17:23.60441102 +0000 UTC m=+80653.473108161 Received: from herokuapp.com (unknown [54.89.20.137]) by ismtpd0029p1iad2.sendgrid.net (SG) with ESMTP id zNDlYfS3RzKpktptkI5--g for ; Fri, 18 Oct 2019 23:17:23.511 +0000 (UTC) Date: Fri, 18 Oct 2019 23:17:23 +0000 (UTC) From: samuel@oriontransfer.net Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 71017 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 16253 X-Redmine-Issue-Author: Dan0042 X-Redmine-Sender: ioquatix 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?cjxb6GWHefMLoR50bkJBcGo6DRiDl=2FNYcMZdY+Wj30Qep3UdduZ4JmhRf2lk1d?= =?us-ascii?Q?u1U4URVLTJqhfLx5mecXDVALGxcceJjT=2FEVw52K?= =?us-ascii?Q?PBP6JuyTNG+kaOtfisrjaau6yW=2FgfKPY1m2ftR2?= =?us-ascii?Q?Msgyv8nbLhbWyfAGfxAI164rBEfcRnnYUoyOg0x?= =?us-ascii?Q?bTb45gUcdtQmTpewRfDYuX3Ajo11mLA1Xvg=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95426 Subject: [ruby-core:95426] [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 ioquatix (Samuel Williams). Here are some real world examples from my code: ``` def self.for(*arguments, &block) self.new(block, *arguments) end # Nicer? def self.for(..., &block) self.new(block, ...) end ``` Module to be prepended: ``` module Connection def initialize(*) super # Other stuff end end # Nicer? module Connection def initialize(...) super(...) # Other stuff end end ``` Many repeated code: ``` def self.one(*arguments, **options) append One.new(*arguments, **options) end def self.many(*arguments, **options) append Many.new(*arguments, **options) end def self.split(*arguments, **options) append Split.new(*arguments, **options) end # Nicer and more maintainble? def self.split(...) append Split.new(...) end ``` There are many more but since this feature is exciting to me, I wanted to give some specific use cases so we can evaluate how they would benefit/change. ---------------------------------------- Feature #16253: Shorthand "forward everything" syntax https://bugs.ruby-lang.org/issues/16253#change-82180 * 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/