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=-2.2 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=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 171D11F463 for ; Fri, 13 Sep 2019 08:17:22 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 5C96E1209A1; Fri, 13 Sep 2019 17:17:13 +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 A9505120994 for ; Fri, 13 Sep 2019 17:17:11 +0900 (JST) Received: by filter0055p3iad2.sendgrid.net with SMTP id filter0055p3iad2-19412-5D7B5088-66 2019-09-13 08:17:12.800151596 +0000 UTC m=+49938.413744891 Received: from herokuapp.com (unknown [54.242.69.183]) by ismtpd0050p1mdw1.sendgrid.net (SG) with ESMTP id GYo5YtHmQMefPRVN3WXNIg for ; Fri, 13 Sep 2019 08:17:12.659 +0000 (UTC) Date: Fri, 13 Sep 2019 08:17:12 +0000 (UTC) From: sawadatsuyoshi@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 70479 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 16166 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=2F5TfLCefGuF4bswOny=2FVAQ1WNQdhs?= =?us-ascii?Q?uzU11wpY0m7nQF9+KdBco4PNtHyNIxEAk12yW6P?= =?us-ascii?Q?Jcngyk31Ni+k8voz53IBb7gNcPaW+pbSAVEGEaa?= =?us-ascii?Q?oOsJ2sm2Bnvn+7RQALqjItWhMqOYmdjd+vWYbN7?= =?us-ascii?Q?8n0E7aWFQtqWDNvJRvosd2Cb8wbMTGz+clQ=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 94925 Subject: [ruby-core:94925] [Ruby master Feature#16166] Remove exceptional handling of *foo when it is the sole block parameter 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 #16166 has been reported by sawa (Tsuyoshi Sawada). ---------------------------------------- Feature #16166: Remove exceptional handling of *foo when it is the sole block parameter https://bugs.ruby-lang.org/issues/16166 * Author: sawa (Tsuyoshi Sawada) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- In the parameter signature of a code block for a method that is not involved in method definition or creation of lambda objects, two types of arguments `["a"]` and `"a"` are neutralized: ```ruby instance_exec(["a"]){|foo, bar| foo} # => "a" instance_exec("a"){|foo, bar| foo} # => "a" instance_exec(["a"]){|*foo, **bar| foo} # => ["a"] instance_exec("a"){|*foo, **bar| foo} # => ["a"] ``` This is the same behavior as with assignment constructions: ```ruby foo, bar = ["a"]; foo # => "a" foo, bar = "a"; foo # => "a" *foo = ["a"]; foo # => ["a"] *foo = "a"; foo # => ["a"] ``` And it contrasts with constructions involved in method definition or creation of lambda objects, where the distinction is preserved: ```ruby lambda{|foo| foo}.call(["a"]) # => ["a"] lambda{|foo| foo}.call("a") # => "a" ->(foo){foo}.call(["a"]) # => ["a"] ->(foo){foo}.call("a") # => "a" lambda{|*foo| foo}.call(["a"]) # => [["a"]] lambda{|*foo| foo}.call("a") # => ["a"] ->(*foo){foo}.call(["a"]) # => [["a"]] ->(*foo){foo}.call("a") # => ["a"] ``` However, when `*foo` is the sole parameter of a code block for a method that is not involved in method definition or creation of lambda objects, `["a"]` and `"a"` are not neutralized: ```ruby instance_exec(["a"]){|*foo| foo} # => [["a"]] instance_exec("a"){|*foo| foo} # => ["a"] ``` behaving in contrast to assignment constructions, and rather on a par with constructions involved in method definition or creation of lambda objects. Particularly, existence or absence another parameter `**bar` entirely changes what `foo` refers to: ```ruby instance_exec(["a"]){|*foo| foo} # => [["a"]] instance_exec(["a"]){|*foo, **bar| foo} # => ["a"] ``` I find this behavior inconsistent and confusing. I would like to request to remove this exceptional handling of a splatted parameter `*foo` when it is the sole parameter in a code block. I request this behavior: ```ruby instance_exec(["a"]){|*foo| foo} # => ["a"] ``` -- https://bugs.ruby-lang.org/