From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-2.4 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_PASS,T_RP_MATCHES_RCVD shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 6E1531F406 for ; Tue, 9 Jan 2018 17:27:05 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 8AECE120A30; Wed, 10 Jan 2018 02:27:02 +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 34218120A2C for ; Wed, 10 Jan 2018 02:26:59 +0900 (JST) Received: by filter0019p3iad2.sendgrid.net with SMTP id filter0019p3iad2-23545-5A54FB60-3E 2018-01-09 17:26:56.578188849 +0000 UTC Received: from herokuapp.com (ec2-54-224-151-203.compute-1.amazonaws.com [54.224.151.203]) by ismtpd0015p1iad2.sendgrid.net (SG) with ESMTP id TUlK2Em8S2qM4GXzlZoXMg Tue, 09 Jan 2018 17:26:56.379 +0000 (UTC) Date: Tue, 09 Jan 2018 17:26:57 +0000 (UTC) From: eregontp@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 60015 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 14344 X-Redmine-Issue-Author: kddeisz X-Redmine-Sender: Eregon 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS5zOW2d0c92V44PBSA8m7qHdQiQ/raft307yB tLhbRMiVOVPJn1r2uI+m1TStVQc82ye4tyXL8qB49ZY5w21Y5dkJdXYt61GNgFlLb50OqKkt18zCui XRUgLE7/03I+G5GN85Sr89tP55CdzMJiNHMXpkfgNh9QZvGIMmtWTiBgew== X-ML-Name: ruby-core X-Mail-Count: 84782 Subject: [ruby-core:84782] [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 Eregon (Benoit Daloze). There is probably room for a shorter syntax for refinements. But one thing which is not acceptable in this specific proposition here is that ~~~ ruby class Test refine String do def refined? true end end # String refinements apply here end ~~~ and ~~~ ruby module Test refine String do def refined? true end end # String refinements do not apply here, it's a normal Module#refine end ~~~ would do two very different things, which is too hard to understand and confusing. Maybe a block to #using would make things slightly shorter: ~~~ ruby class Test using do refine String do def refined? true end end end end ~~~ ---------------------------------------- Feature #14344: refine at class level https://bugs.ruby-lang.org/issues/14344#change-69498 * 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/