From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-2.9 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_PASS,T_RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 31F6D1F576 for ; Wed, 24 Jan 2018 11:52:57 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 8A0AD120A8C; Wed, 24 Jan 2018 20:52:55 +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 87984120A89 for ; Wed, 24 Jan 2018 20:52:52 +0900 (JST) Received: by filter0010p3mdw1.sendgrid.net with SMTP id filter0010p3mdw1-14822-5A6856B5-12 2018-01-24 09:49:41.21264853 +0000 UTC Received: from herokuapp.com (ec2-50-19-14-97.compute-1.amazonaws.com [50.19.14.97]) by ismtpd0012p1iad2.sendgrid.net (SG) with ESMTP id rejZ6EXSSRilP-yx3fMPbg Wed, 24 Jan 2018 09:49:41.194 +0000 (UTC) Date: Wed, 24 Jan 2018 09:49:41 +0000 (UTC) From: zverok.offline@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 60282 X-Redmine-Project: common-ruby X-Redmine-Issue-Id: 13581 X-Redmine-Issue-Author: americodls X-Redmine-Sender: zverok 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: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS7mrXN63ZWKchSUqr4c4auPaalLonqrnWsm7l MImhB3J0C5DnlhnTlvO2rX1Q1w5wqPH5r1VAf2Ig0GzK1krdzozXGW3aEBeZ1RGUn5KFT88jZo+PQb LyclO3aahWno+rm2MT+Ne5J0247oiSCTroEar9NHHw2cfJs7gudA34aZXQ== X-ML-Name: ruby-core X-Mail-Count: 85038 Subject: [ruby-core:85038] [CommonRuby Feature#13581] Syntax sugar for method reference 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 #13581 has been updated by zverok (Victor Shepelev). Just to push this forward, here are all the syntaxes from this and duplicate #12125. I am taking `Math.sqrt` and `puts` as examples: * `map(&Math->sqrt)` (and just `each(&->puts)` probably?) -- Matz is explicitly against it; * `map(&Math\.sqrt)` (not sure about puts); * `map(&Math.m(:sqrt))`, `each(&m(:puts))` (just shortening, no language syntax change) * `map(&Math.:sqrt)`, `each(&.:puts)` * `map(&Math:sqrt)`, `each(&self:puts)` * `map(&Math#sqrt)`, `each(&#puts)` (it was my proposal, "just how it looks in docs", but I should reconsider: in docs it is `Math::sqrt`, in fact) * `map(&Math:::sqrt)`, `each(&:::puts)` * `map(&~>(:sqrt, Math)`), `each(&~>(:puts))` * [several](https://bugs.ruby-lang.org/issues/12125#note-4) by @Papierkorb: * `map(&Math.>sqrt)`, `each(&.>puts)` * `map(&Math)`, `each(&)` (@nobu: conflicts with existing syntax) * `map(&Math&>sqrt)`, `each(&&>puts)` (@nobu: conflicts with existing syntax) * `map(&Math|>sqrt)`, `each(&|>puts)` (too confusable with Elixir-like pipe, probably) Can please please somebody lift this question to next Developer Meeting and make an Executive Decision?.. I personally really like `.:` (called "tetris operator" in other ticket). ---------------------------------------- Feature #13581: Syntax sugar for method reference https://bugs.ruby-lang.org/issues/13581#change-69758 * Author: americodls (Americo Duarte) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- Some another programming languages (even Java, in version 8) has a cool way to refer a method as a reference. I wrote some examples here: https://gist.github.com/americodls/20981b2864d166eee8d231904303f24b I miss this thing in ruby. I would thinking if is possible some like this: ~~~ roots = [1, 4, 9].map &Math.method(:sqrt) ~~~ Could be like this: ~~~ roots = [1, 4, 9].map Math->method ~~~ What do you guys thinking about it? -- https://bugs.ruby-lang.org/