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.0 required=3.0 tests=AWL,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 784281F45A for ; Wed, 14 Aug 2019 06:59:52 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id E9884120AD8; Wed, 14 Aug 2019 15:59:45 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id DFEFE120AD7 for ; Wed, 14 Aug 2019 15:59:43 +0900 (JST) Received: by filter0118p3las1.sendgrid.net with SMTP id filter0118p3las1-9706-5D53B162-F 2019-08-14 06:59:46.347542227 +0000 UTC m=+1596634.311172666 Received: from herokuapp.com (unknown [54.224.29.177]) by ismtpd0004p1iad1.sendgrid.net (SG) with ESMTP id 3IzCWmtiRRqOXwN3raDe3w for ; Wed, 14 Aug 2019 06:59:46.199 +0000 (UTC) Date: Wed, 14 Aug 2019 06:59:46 +0000 (UTC) From: sawadatsuyoshi@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 69889 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 16102 X-Redmine-Issue-Author: sawa X-Redmine-Sender: sawa 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?jFXA8Rt481sXUUIO9tYW1AJlMOZdNdlSw=2F5TfLCefGs5Z44ueqEIPpvo8vckMg?= =?us-ascii?Q?nafaGRuxzOJ52DyZHcURKYQifZK89kFdlwmJg2E?= =?us-ascii?Q?QZRZAAVgr6PssoYjn6yypVBoy7wiSOpeQP2lXsh?= =?us-ascii?Q?n5px7RcguFfFmmwvZWDRKppCpcAv6Sls0obS0VB?= =?us-ascii?Q?RLA=2FUXHBS3ByBu991FcEAYwvjJ65mqlM0xA=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 94342 Subject: [ruby-core:94342] [Ruby master Feature#16102] `Symbol#call` 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 #16102 has been reported by sawa (Tsuyoshi Sawada). ---------------------------------------- Feature #16102: `Symbol#call` https://bugs.ruby-lang.org/issues/16102 * Author: sawa (Tsuyoshi Sawada) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- Since symbols have a `to_proc` method, it is natural to expect that they would appear in a method chain like: ```ruby :some_symbol.to_proc.call(...) ``` In fact, I have use cases like this: ```ruby arrays = [["a", "b"], ["c"], ["d", "e"]] hashes = [{"a" => 1}, {"b" => 2, "c" => 3}, {"d" => 4, "e" => 5}] :product.to_proc.(*arrays) # => [["a", "c", "d"], ["a", "c", "e"], ["b", "c", "d"], ["b", "c", "e"]] :zip.to_proc.(*arrays) # => [["a", "c", "d"], ["b", nil, "e"]] :union.to_proc.(*arrays) # => ["a", "b", "c", "d", "e"] :merge.to_proc.(*hashes) # => {"a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5} ``` I request `Symbol#call` to be defined, which would implicitly call `to_proc` on the receiver and then the conventional `Proc#call` on the result. Then, I can do: ```ruby :product.(*arrays) # => [["a", "c", "d"], ["a", "c", "e"], ["b", "c", "d"], ["b", "c", "e"]] :zip.(*arrays) # => [["a", "c", "d"], ["b", nil, "e"]] :union.(*arrays) # => ["a", "b", "c", "d", "e"] :merge.(*hashes) # => {"a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5} ``` Notice that proposals #12115 and #15301 ask for `Symbol#call`, but they ask for different things (a method that returns a proc), and are irrelevant to the current proposal. -- https://bugs.ruby-lang.org/