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.8 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,SPF_PASS, T_DKIM_INVALID shortcircuit=no autolearn=no 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 5E56D208CD for ; Thu, 31 Aug 2017 13:12:46 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 114BF120932; Thu, 31 Aug 2017 22:12:44 +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 1A06F120929 for ; Thu, 31 Aug 2017 22:12:41 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=KXRJglL+17IbK8fCRI7vGiyU1Vs=; b=nUAA/oTdqJrWXL8V54 7lhQyi1AtCpFDIKvzvrw5HfSsGG3nK3tD3fHByIU9FlfHY24SRhAZjLpAntukfXV bn4s4zgoaHhgt/sVRjfj4sUJP/CoC8NYxMcXekGrSzGjszCEG07TUY/YEB9ZY060 QTBNmiqz3AlkOua1UZzQWRx2Y= Received: by filter0005p3las1.sendgrid.net with SMTP id filter0005p3las1-13191-59A80B46-11 2017-08-31 13:12:38.352309268 +0000 UTC Received: from herokuapp.com (ec2-54-221-81-61.compute-1.amazonaws.com [54.221.81.61]) by ismtpd0006p1iad1.sendgrid.net (SG) with ESMTP id wTolelgLRw6FOp_pHsrs4g Thu, 31 Aug 2017 13:12:38.180 +0000 (UTC) Date: Thu, 31 Aug 2017 13:12:38 +0000 (UTC) From: takashikkbn@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 57640 X-Redmine-Project: common-ruby X-Redmine-Issue-Id: 13581 X-Redmine-Issue-Author: americodls X-Redmine-Sender: k0kubun 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS6fOyFv4qaID9yKGNYEuPAg97QBt+GIBwDEOH 9gYeLyONdVMpL417vrTzYZ90aYfCpoTCXdIus9inMFNAHsGv8Umm5BnPTaryoV3CbKAxHISTiFzFMX 1CmIvPh9LlSlYbqzVRyay08fPYbyCJvz84NUCSGBAaIdFzPBVzkpvTuZ2A== X-ML-Name: ruby-core X-Mail-Count: 82586 Subject: [ruby-core:82586] [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 k0kubun (Takashi Kokubun). Oh, I'm so sad to hear obj:method (without &) is already valid. I still have hope to have it only when it's put with & in the last of arguments because that case is not valid for now. ```ruby irb(main):001:0> def obj(method); method; end => :obj irb(main):002:0> obj:method => :method irb(main):003:0> obj(&obj:method) SyntaxError: (irb):3: syntax error, unexpected tSYMBEG, expecting keyword_do or '{' or '(' obj(&obj:method) ^ from /home/k0kubun/.rbenv/versions/2.4.1/bin/irb:11:in `
' irb(main):004:0> obj(&(obj:method)) SyntaxError: (irb):4: syntax error, unexpected tLABEL obj(&(obj:method)) ^ from /home/k0kubun/.rbenv/versions/2.4.1/bin/irb:11:in `
' ``` I've never seen a person who writes a(:b) as a:b and personally I don't expect &a:b to be &a(:b). ---------------------------------------- Feature #13581: Syntax sugar for method reference https://bugs.ruby-lang.org/issues/13581#change-66408 * 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/