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.1 required=3.0 tests=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_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 C0BD2211B4 for ; Fri, 11 Jan 2019 16:05:07 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 161BF1211E9; Sat, 12 Jan 2019 01:05:04 +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 9BD80121154 for ; Sat, 12 Jan 2019 01:05:01 +0900 (JST) Received: by filter0041p3iad2.sendgrid.net with SMTP id filter0041p3iad2-31830-5C38BEA9-6E 2019-01-11 16:04:57.90162578 +0000 UTC m=+314677.125841106 Received: from herokuapp.com (ec2-54-80-22-201.compute-1.amazonaws.com [54.80.22.201]) by ismtpd0017p1iad1.sendgrid.net (SG) with ESMTP id G880TZkcRPiOXHE6XaSbpQ Fri, 11 Jan 2019 16:04:57.877 +0000 (UTC) Date: Fri, 11 Jan 2019 16:04:58 +0000 (UTC) From: dementiev.vm@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 66460 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 14344 X-Redmine-Issue-Author: kddeisz X-Redmine-Sender: palkan 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS4s0NIHEagpCydRocsQPXUwS7EVD/P/Z/WYtt LJZLDwptwjsQH/tHHnf3jJnFZnFtROpcaMW+jr3F5TsV/zs7TvET5DAYTOmd6ZcVcUJZRqo9TxudcQ z1/du9qG4EHmxSVKAjin6esrICLDN9F6u0cFpTjj4gzo0VeWbljlM+pLZw== X-ML-Name: ruby-core X-Mail-Count: 91026 Subject: [ruby-core:91026] [Ruby trunk Feature#14344] refine at class level 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 #14344 has been updated by palkan (Vladimir Dementyev). shevegen (Robert A. Heiler) wrote: > I think that: > > using do > refine Array do > > Is not good. It looks very strange to me. On the other hand, it's closer to what we have to write now (`using(Module.new do`) and it doesn't have any additional constraints like being at the top level of class/module context dependent. > > The other variants, such as the original one: > > class Test > refine String do > The problem with this approach has been already mentioned by Benoit ([[https://bugs.ruby-lang.org/issues/14344#note-7]]): the behaviour of `refine` changes depending on whether we're in the module or class context. IMO, it would introduce even more confusion. And the goal of this feature, as it has been said, is to lower the barrier. > (On a side note, I think you added it to the recent developer meeting > which already happened) Oops, I got lost in time) thanks for noticing! ---------------------------------------- Feature #14344: refine at class level https://bugs.ruby-lang.org/issues/14344#change-76248 * Author: kddeisz (Kevin Deisz) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- I rely on refinements a lot, but don't want to keep writing `Module.new` in code. I'm proposing `Object::refine`, which would create an anonymous module behind the scenes with equivalent functionality. So: ~~~ ruby class Test using Module.new { refine String do def refined? true end end } end ~~~ would become ~~~ ruby class Test refine String do def refined? true end end end ~~~ It's a small change, but reads a lot more clearly. Thoughts? -- https://bugs.ruby-lang.org/