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 B66B71F4C0 for ; Fri, 18 Oct 2019 23:33:55 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 3A423120B1A; Sat, 19 Oct 2019 08:33:45 +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 BA9AF120B11 for ; Sat, 19 Oct 2019 08:33:42 +0900 (JST) Received: by filter0194p3mdw1.sendgrid.net with SMTP id filter0194p3mdw1-20199-5DAA4BD7-22 2019-10-18 23:33:43.512649608 +0000 UTC m=+95006.914216366 Received: from herokuapp.com (unknown [54.89.20.137]) by ismtpd0060p1iad2.sendgrid.net (SG) with ESMTP id -DTu-S_6SMOK4Fqw37S5Tg for ; Fri, 18 Oct 2019 23:33:43.181 +0000 (UTC) Date: Fri, 18 Oct 2019 23:33:43 +0000 (UTC) From: merch-redmine@jeremyevans.net Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 71018 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 16253 X-Redmine-Issue-Author: Dan0042 X-Redmine-Sender: jeremyevans0 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?RVE3t853K5scBhbmJHUzZTFFeVC=2FZSUmHZ0Dc+26wcEi2CTgsF1oz0wTSSxGGN?= =?us-ascii?Q?BIOt6BkoEYWS5Y=2FmgooQsNsbFtRK2Ev+tM7XcFJ?= =?us-ascii?Q?hDtXUKiTQ3l5vPgizGN8QRmSisVwFw1AmI7Dzp+?= =?us-ascii?Q?I4ymudAgZuTU9kEFNtBM8gchTlYL+deEsBXHaaU?= =?us-ascii?Q?sk+B6XOpIpAe2NEdwBI20Q3=2FCa2T55bIWuQ=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95427 Subject: [ruby-core:95427] [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 jeremyevans0 (Jeremy Evans). ioquatix (Samuel Williams) wrote: > 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 > ``` >From reading the last dev meeting log (under `Future work: lead argument handling is postponed`), this will not be supported, at least initially. > Module to be prepended: > > ``` > module Connection > def initialize(*) > super > > # Other stuff > end > end > > # Nicer? > > module Connection > def initialize(...) > super(...) > > # Other stuff > end > end > ``` I think a bare `super` makes more sense than `super(...)`, and it is backwards compatible. However, in order to avoid keyword argument separation issues, if the super method accepts keyword arguments, you need to do `def initialize(*, **)` instead of `def initialize(*)` (`def initialize(...)` should also work). > Many repeated code: > > ``` > def self.split(*arguments, **options) > append Split.new(*arguments, **options) > end > > # Nicer and more maintainable? > > def self.split(...) > append Split.new(...) > end > ``` Definitely looks nicer, so if you don't care about backwards compatibility, it seems like a good change. ---------------------------------------- Feature #16253: Shorthand "forward everything" syntax https://bugs.ruby-lang.org/issues/16253#change-82181 * 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/