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 612701A600EE for ; Wed, 29 Jun 2016 20:37:27 +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 5B671B5D977 for ; Wed, 29 Jun 2016 21:12:08 +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 F057318CC831 for ; Wed, 29 Jun 2016 21:12:08 +0900 (JST) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 835A2120452; Wed, 29 Jun 2016 21:12:08 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o10.shared.sendgrid.net (o10.shared.sendgrid.net [173.193.132.135]) by neon.ruby-lang.org (Postfix) with ESMTPS id 4641E120449 for ; Wed, 29 Jun 2016 21:12:05 +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=1o2Fze5levlAK/6q8pgqbmXBBiI=; b=unCCKKxdGlDqZfKcyK Urad85ZGAd4ebS3O8rGI/ainIOPH3rqfHvghIkWjo00VcwFIhr1Z46XjWHp/mNv1 xilSmIN+VYosmbud1I8TOclSPq+g/n0XbxtcXfeYp6h06qbuTWW4AjT/c2X3dpr5 Qdg5/l0Dzd6eFa2n4UWcS4q+M= Received: by filter0546p1mdw1.sendgrid.net with SMTP id filter0546p1mdw1.1088.5773BB0070 2016-06-29 12:11:44.718056532 +0000 UTC Received: from herokuapp.com (ec2-54-80-204-171.compute-1.amazonaws.com [54.80.204.171]) by ismtpd0001p1iad1.sendgrid.net (SG) with ESMTP id wq9UgZ4tRXKG_dyg3y000w for ; Wed, 29 Jun 2016 12:11:44.517 +0000 (UTC) Date: Wed, 29 Jun 2016 12:11:44 +0000 From: cardoso_tiago@hotmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 50928 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 12533 X-Redmine-Issue-Author: chucke X-Redmine-Sender: chucke 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS4MLTffDe10FScch+3pZNVI0nukY/Dc1t1EL5 ptU5PRvP2R99fhHFDBHb/BLZkUXZSc56pq6oeA3YNFczPpP/0edmUymGjuqnbierUqyKkzX8qhx4vb GKtzY3Q9E+kWNWpRiRnV+OV/ehfCAR0jQhWNrXXzD4vXJGgy58sHS9dnUQ== X-ML-Name: ruby-core X-Mail-Count: 76197 Subject: [ruby-core:76197] [Ruby trunk Feature#12533] 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 reported by Tiago Cardoso. ---------------------------------------- Feature #12533: Refinements: allow modules inclusion, in which the module can call internal methods which it defines. https://bugs.ruby-lang.org/issues/12533 * Author: Tiago Cardoso * Status: Open * Priority: Normal * Assignee: ---------------------------------------- Right now this isn't possible:
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 methodvegetables' 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/