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 (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id BC2ED1A600EE for ; Wed, 29 Jun 2016 20:38:33 +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 BDF1AB5D887 for ; Wed, 29 Jun 2016 21:13:14 +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 5DE7B18CC836 for ; Wed, 29 Jun 2016 21:13:15 +0900 (JST) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id CD02F120459; Wed, 29 Jun 2016 21:13:15 +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 31ABB120449 for ; Wed, 29 Jun 2016 21:13:11 +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=uS8ePQTYTpzPyRYc/8XGlxDEkYY=; b=nZ24i8hsERw1SdJpHl C1v/bTKBf+Y4ajeBfmLIWO3MnIOgeDKT/U5Pir0EIEhxHVGMCGhXuwI52x8YBYP3 UTwn07gieGPCvyAD9qhtvd9dl4NMTCHIvU2moa+qFaZQicjJ/CIR6C6PZOZcI9Ez 3DHKfWvICjFovAjPplp10kVyU= Received: by filter0604p1mdw1.sendgrid.net with SMTP id filter0604p1mdw1.18914.5773BB4A42 2016-06-29 12:12:58.407122907 +0000 UTC Received: from herokuapp.com (ec2-54-80-220-93.compute-1.amazonaws.com [54.80.220.93]) by ismtpd0001p1iad1.sendgrid.net (SG) with ESMTP id Kwkc8QX9TUqRQfwYvwyLPg for ; Wed, 29 Jun 2016 12:12:58.352 +0000 (UTC) Date: Wed, 29 Jun 2016 12:12:57 +0000 From: cardoso_tiago@hotmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 50929 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS78Y5uxRQoqHk+6xCegWZroD1LaaBfXRFFzPl Z5vU3ZKmW3H31/dF0CNBpWxJADsIGMk86B9JGu2c6/z2lwVsfeVMhBXZDxzfSw5PG6iP3A9NQZXaoE aFpQDroX/SuzzDQXMTyHP60+56Xfy4wrkVOYS/7et86uuVwT8HxEgZhMiQ== X-ML-Name: ruby-core X-Mail-Count: 76198 Subject: [ruby-core:76198] [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 updated by Tiago Cardoso. Sorry about the UI for the gist, apparently I don't know anymore how to properly declare code blocks in redmine... ---------------------------------------- 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-59414 * 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/