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.7 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 A3BFA1F4BD for ; Sat, 5 Oct 2019 22:06:11 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id C288912096F; Sun, 6 Oct 2019 07:06:01 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 1DA3D120939 for ; Sun, 6 Oct 2019 07:05:58 +0900 (JST) Received: by filter0138p3las1.sendgrid.net with SMTP id filter0138p3las1-15964-5D9913C7-A 2019-10-05 22:05:59.100547846 +0000 UTC m=+349137.144535272 Received: from herokuapp.com (unknown [18.234.90.121]) by ismtpd0033p1mdw1.sendgrid.net (SG) with ESMTP id md6quo-WQD2vzjLz-h_4qg for ; Sat, 05 Oct 2019 22:05:58.939 +0000 (UTC) Date: Sat, 05 Oct 2019 22:05:59 +0000 (UTC) From: zverok.offline@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 70823 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 16241 X-Redmine-Issue-Author: palkan 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: =?us-ascii?Q?3be0g8093pjUjT94eiCA64csFDBI=2FmHQTWm54P5gda4h2415ewqkRnTJcn6lyU?= =?us-ascii?Q?VZOppS0hhOEz8uxRyhiTxQbef0rXoEwjuciH6Pj?= =?us-ascii?Q?y=2FV2qrvAzR96tIqmYKxYSf0YvPEh2MUnGgWfLoy?= =?us-ascii?Q?swdYieL1a3Dif8KOAbG5jNp6LcGsPLERXdZcof3?= =?us-ascii?Q?7XBLkdvHrosmB7bicuTR5JjKL+hMlM9UW1w=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95236 Subject: [ruby-core:95236] [Ruby master Feature#16241] Shorter syntax for anonymous refinements 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 #16241 has been updated by zverok (Victor Shepelev). I believe that is really super-good thing. As I've written elsewhere in this tracker, the most useful case for refinements is "in current module, I want some shortcuts for my code to look cleaner". For example, [here](https://github.com/zverok/drosterize) and [here](https://github.com/zverok/xkcdize) I experimented with representing some graphics algorithm in a most "readable" way, adding really small methods to core (Numeric) and RMagick objects. The point is "here, in this module, I crave for some things to exists in some objects". So, "inplace refinements" is probably the main kind of refinements the developer could care; while "refinements in a module" could be used, probably, for some "more hygienic" ActiveSupport-alike gems, or some specific blends of Ruby (like `using Geometry` with ton of specific geometry-related services added to numbers and matrices and whatnot). ---------------------------------------- Feature #16241: Shorter syntax for anonymous refinements https://bugs.ruby-lang.org/issues/16241#change-81909 * Author: palkan (Vladimir Dementyev) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- The original discussion is here https://bugs.ruby-lang.org/issues/14344. tl;dr - Refinements are often used in-place with anonymous modules - Having shorter syntax could lower the barrier of entry for Rubyist wanting to explore this feature - Previous syntax suggestions were not accepted. I suggest adding a shorter syntax (technically, API): ```ruby # before using(Module.new do refine Array do def foo;"bar";end end end) # after refining Array do def foo; "bar"; end end ``` The original idea was to use `using_refined` instead of `refining` but after discussing with Matz we decided that it's too verbose, and `refining` seems better. But is it good enough? Any thoughts? -- https://bugs.ruby-lang.org/