From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from nue.mailmanlists.eu (nue.mailmanlists.eu [94.130.110.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 0078C1F4BE for ; Tue, 22 Oct 2024 20:21:40 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; unprotected) header.d=ml.ruby-lang.org header.i=@ml.ruby-lang.org header.a=rsa-sha256 header.s=mail header.b=g+MSJXt5; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=SxR2yLdP; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1729628467; bh=npOcFZYh1+9mVVDWu4t6MVrWUnbAUsMZMoyw/fuewnA=; h=Date:References:To:Reply-To:Subject:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From:Cc:From; b=g+MSJXt5Qv62YYHNmKv+rEv7JuNeyAVjEELICDSbZd0ocIODFo0u6jIun00yCvIxp EupVs1wHNBNtleDHhOS2asBUPI2VWO2z4PSil/17Ogek7u/KsrpeWJId6C0WST/9/6 TC0olU5SKZBN2VzICyfETA7zJfkDvuCgP8KUYxP4= Received: from nue.mailmanlists.eu (localhost [IPv6:::1]) by nue.mailmanlists.eu (Postfix) with ESMTP id C485444670 for ; Tue, 22 Oct 2024 20:21:07 +0000 (UTC) Authentication-Results: nue.mailmanlists.eu; dkim=pass (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=SxR2yLdP; dkim-atps=neutral Received: from s.wfbtzhsw.outbound-mail.sendgrid.net (s.wfbtzhsw.outbound-mail.sendgrid.net [159.183.224.105]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 6E530445B0 for ; Tue, 22 Oct 2024 20:20:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ruby-lang.org; h=from:references:subject:mime-version:content-type: content-transfer-encoding:list-id:to:cc:content-type:from:subject:to; s=s1; bh=QpYqihi4blax7hBPGIPkr2jn0O7AuESb5meXeFxUNRg=; b=SxR2yLdPxS+I4owh8kGbVT7Bz7shWjP20gFGOCbQhmumzCl03u+EgtrA/XZ07nz7eaLa twVtLiJMMyUBNpKHl+OnF4MlXo5LBMdjTfvhCZgUt2iso1ltzO0ZYg78j33yY2tUPaFDhV JojC91Z+1jx7tuBjNYstme35X9XfngvUWAdjtMmqJJTGWVRrjUUAJZEcneG45t+eCV+9jp ijCMk3UmCdzzel+Q4axM2GWPiJQ5vY5N037BXxuFT0rpRjomi41nSY+1uwP5eJjD3bh6X4 2NayMY090HSL5LYJ51FaREaUPgSosQhCH1BS+0ypAB4Cjiyfk0E3cwnOK/g9V2aw== Received: by recvd-5577bcb48c-x6nqm with SMTP id recvd-5577bcb48c-x6nqm-1-67180927-F 2024-10-22 20:20:55.485990766 +0000 UTC m=+3464694.307591976 Received: from herokuapp.com (unknown) by geopod-ismtpd-40 (SG) with ESMTP id MDjytjqaRGuAjQtQfx-zrA for ; Tue, 22 Oct 2024 20:20:55.452 +0000 (UTC) Date: Tue, 22 Oct 2024 20:20:55 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 15381 X-Redmine-Issue-Author: sawa X-Redmine-Issue-Priority: Normal X-Redmine-Sender: Dan0042 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-Redmine-MailingListIntegration-Message-Ids: 96226 X-SG-EID: =?us-ascii?Q?u001=2EHy4LB1bizMxDg=2Fk6r7dYDS9qUDe3jZN8DIPm4OS+F86l7XdLFEAVX=2F2lh?= =?us-ascii?Q?z0Jj=2Ft7J6DgKnq5Qaf6Ba4+egck=2FoKuUHMa9Cn6?= =?us-ascii?Q?7D+EQ8vUJVuUhC1JuxScfwRNhZee3qeHst9Y6dg?= =?us-ascii?Q?D6SbARo=2FVNHo59iDbqKbGVNLhYN76c9hxS5qqvu?= =?us-ascii?Q?3p5lq1wSyCUr2+YUXn95PxoL11kcJwun9=2F5trPP?= =?us-ascii?Q?pzAZgVPaaEEtp0Cy=2FAO2F6aeYhc+1CwrZsxT=2F3w?= =?us-ascii?Q?5MJ6ea=2FwODYkLjka5rED=2FlAWug=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: GW22XA4EP6S2NCH6ND45ZZ5U5E6YWJCN X-Message-ID-Hash: GW22XA4EP6S2NCH6ND45ZZ5U5E6YWJCN X-MailFrom: bounces+313651-b711-ruby-core=ml.ruby-lang.org@em5188.ruby-lang.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list Reply-To: Ruby developers Subject: [ruby-core:119592] [Ruby master Feature#15381] Let double splat call `to_h` implicitly List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "Dan0042 (Daniel DeLorme) via ruby-core" Cc: "Dan0042 (Daniel DeLorme)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #15381 has been updated by Dan0042 (Daniel DeLorme). > There are certainly backwards compatibility issues from changing `**` from calling `to_hash` to `to_h`. What kind of backwards compatibility issues exactly? My idea was to call #to_hash and fall back to #to_h, that should ensure no backwards incompatibility at all, unless I'm missing something? > Using the unary `**` operator on an object would call the `**@` method, which should return a hash (or raise an exception). That's a very intriguing solution, and very elegant I have to say. ---------------------------------------- Feature #15381: Let double splat call `to_h` implicitly https://bugs.ruby-lang.org/issues/15381#change-110213 * Author: sawa (Tsuyoshi Sawada) * Status: Open ---------------------------------------- The single splat calls `to_a` implicitly on the object (if it is not an array already) so that, for example, we have the convenience of writing conditions in an array literal: ```ruby a = [ *(:foo if some_condition), *(:bar if another_condition), ] ``` And the ampersand implicitly calls `to_proc` on the object (if it is not a proc already) so that we can substitute a block with an ampersand followed by a symbol: ```ruby some_method(&:some_method_name) ``` Unlike the single splat and ampersand, the double splat does not seem to implicitly call a corresponding method. I propose that the double splat should call `to_h` implicitly on the object if it not already a Hash so that we can, for example, write a condition in a hash literal as follows: ```ruby h = { **({a: 1} if some_condition), **({b: 2) if another_condition), } ``` There may be some other benefits of this feature that I have not noticed yet. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/