From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (smtp.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id B37C21A601F4 for ; Fri, 8 Jul 2016 15:48:05 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id D7575B5D860 for ; Fri, 8 Jul 2016 16:22:30 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 53E0818CC834 for ; Fri, 8 Jul 2016 16:22:31 +0900 (JST) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id BB0B7120491; Fri, 8 Jul 2016 16:22:30 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o2.heroku.sendgrid.net (o2.heroku.sendgrid.net [67.228.50.55]) by neon.ruby-lang.org (Postfix) with ESMTPS id 78C7D120460 for ; Fri, 8 Jul 2016 16:22:27 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=802EmRckxUI7iMue1kqveHbpXLA=; b=Ga+mg5x8/lndUM9Ca0 Yc9qGIyYEdVECzDdC287urDguRO+rgyyA47kKNNYWkHyY/x1Ck3E9orBCrKEZ+3Q dYmBTv/RpXXFW3t0A9pOLe/RMyjug7zS1EjbotD4aQNW8q25FRVzYNxiu6Hj+it7 Gpb9KKvzhGgMyZkKM/pFhNZp8= Received: by filter0806p1mdw1.sendgrid.net with SMTP id filter0806p1mdw1.30919.577F54AA8 2016-07-08 07:22:18.129785338 +0000 UTC Received: from herokuapp.com (ec2-54-166-160-80.compute-1.amazonaws.com [54.166.160.80]) by ismtpd0005p1iad1.sendgrid.net (SG) with ESMTP id OdNwBq4oQc6z79Bqq23b-w for ; Fri, 08 Jul 2016 07:22:18.112 +0000 (UTC) Date: Fri, 08 Jul 2016 07:22:17 +0000 From: shugo@ruby-lang.org To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 51070 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 12533 X-Redmine-Issue-Author: chucke X-Redmine-Issue-Assignee: matz X-Redmine-Sender: shugo 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS7B4YOmTB2ipR94EX7/wDMO1UiICZ9XvXMYUm RlPEuziZMcnq86RYFcr5DIpMqYoypP/oQHpsdCCBYqfbAo5z83Ubp4l3Ogq+JHWUe4DrGlqijeAyHG 3lWPgS3TLO7Em/bA6B9jLawEseuezo3PR13AvJSFVyed/aD0kU6hsT7RPA== X-ML-Name: ruby-core X-Mail-Count: 76315 Subject: [ruby-core:76315] [Ruby trunk Feature#12533][Assigned] Refinements: allow modules inclusion, in which the module can call internal methods which it defines. 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 #12533 has been updated by Shugo Maeda. Status changed from Open to Assigned Assignee set to Yukihiro Matsumoto Matz, what do you think of this? Local rebinding may be worth considering, but there is a trade-off. ---------------------------------------- Feature #12533: Refinements: allow modules inclusion, in which the module can call internal methods which it defines. https://bugs.ruby-lang.org/issues/12533#change-59551 * Author: Tiago Cardoso * Status: Assigned * Priority: Normal * Assignee: Yukihiro Matsumoto ---------------------------------------- Right now this isn't possible: ~~~ruby module Extensions def vegetables ; potatoe ; end def potatoe ; "potatoe" ; end end module Refinary refine String do # this doesn't work include Extensions # this would work... # def vegetables ; potatoe ; end # def potatoe ; "potatoe" ; end end end using Refinary puts "tomatoe".vegetables #=> in
': undefined method 'vegetables' for "tomatoe":String ~~~ Wrongly reported as a bug [here](https://bugs.ruby-lang.org/issues/12514). According to Shugo Maeda, this was expected behaviour. I argued that this is the way most monkey-patches work, and if Refinements can't cover the use case of inserting a custom DSL which references itself in the classes it refines, it can't fully replace monkey-patches, which I read was the main reason Refinements have been added to the language. -- https://bugs.ruby-lang.org/