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 E15D61BA010B for ; Mon, 22 May 2017 01:44:46 +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 2EB60B5D864 for ; Mon, 22 May 2017 02:30:46 +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 2BA2418CC80E for ; Mon, 22 May 2017 02:30:45 +0900 (JST) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 68A6A12076A; Mon, 22 May 2017 02:30:44 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 5376D12073E for ; Mon, 22 May 2017 02:30:40 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=B6+KZ3nPtiUtRwkjWZ8ynYAVc8s=; b=GDV2vcRBr5t4/YE+V8 ryvJA5HyfHwLIa3MYXL+xnQaYIjGTMxLMupsafZOlNIga89YQLA36J4+vI1Zdp+5 FzqZb3MA5JRXx/PPgtpZGtU0f9oFz66zB7GM3W3XKyKEOeGrXS/8ORBJ1hbE9qte DmyyfPZm1KhvM4m7cSVBmb7mA= Received: by filter0621p1mdw1.sendgrid.net with SMTP id filter0621p1mdw1-3885-5921CE8E-6A 2017-05-21 17:29:50.980454692 +0000 UTC Received: from herokuapp.com (ec2-54-234-105-146.compute-1.amazonaws.com [54.234.105.146]) by ismtpd0001p1iad1.sendgrid.net (SG) with ESMTP id 6Q-01jN-Q4m0jtFWd85aUg Sun, 21 May 2017 17:29:50.896 +0000 (UTC) Date: Sun, 21 May 2017 17:29:50 +0000 From: shevegen@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 56347 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 13551 X-Redmine-Issue-Author: JustJosh X-Redmine-Sender: shevegen 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS4jj0+qhU/LwEkBWPzeg2oLM6npdNkAMEfPsz qUJ360pZB0Vu4WIHi//7J3fnFGjQCkMFr8DVp6qXxm2/w/8xIy8Cu7gAXYZcnFmrGgS9JDXXTQAFMW HYGEqHkWxolJglvrJfCCWxocqVvles//SU12zT5ADCcXGCm/282lYdyzIg== X-ML-Name: ruby-core X-Mail-Count: 81319 Subject: [ruby-core:81319] [Ruby trunk Feature#13551] Add a method to alias class methods 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 #13551 has been updated by shevegen (Robert A. Heiler). > Given that it's very easy (as shown by Matthew) to create such a method, do you think it's necessary that this > be implemented by Ruby itself? You haven't yet answered the question about frequency of use or use cases. Well I do not have a statistical dataset myself, but I use it all the time. The thing is that for me it is very natural to use "alias". def foo; puts 'hi from foo()'; end alias bar foo I love it. I love aliases. They make me happy. :) I use aliases mostly because I have a bad memory. And also because I want to remain flexible. Some time ago I started to adopt a more "logical" scheme with my classes, when it may make sense. For example, most of my classes, if necessary, have a "reset" method. Often I also have a "menu" method, which I consider as the interface that can parse the commandline (or optionally any other input that is sent to it). And so on and so forth. So in this context, I totally agree with Joshua Stowers. I think that ruby itself should not care too much if a user wants to use an alias on the class/module level instance or within the context of self with regular instance methods of the class. So here, I agree with Joshua. The awkward thing, though, is that I actually dislike the syntax proposal: alias_class_method :new_name, :old_name The reason is, and this may be trivial, is that I really really hate the ',' character there. The symbols are ok although it's better to avoid them. I also understand that alias_method is not the same as alias, but alias is so cute and short, it is just built to be loved! Now you may wonder, how do I alias class methods then? I use a VERY clumsy way. I do not recommend anyone to use it and I am sure there are better ways but here goes: self.instance_eval { alias stop_codons stop_codons? } I dislike the self.instance_eval part because it is so long and verbose - but I love the alias part within the { } because to my eyes, it is neat and cuddly. I can't say whether I would use alias_class_method - the name is not soooo bad (though, what if we have a module Foo; end method? Do we call it alias_module_method then?), but I am not sure about the syntax. BUT I also dislike typing the: self.instance_eval { } part altogether, so in this context, I agree with Joshua Stowers. (I also understand that one should not use too many aliases but I love aliases. The main method is usually the one I use the most, and then I may use some aliases, some for backwards compatbility and sometimes I remove them too at a later point so it just provides some more flexibility "as you go".) Anything that would be as neat or almost as short as: "alias foo bar" but for class-methods / module-methods would be great! ---------------------------------------- Feature #13551: Add a method to alias class methods https://bugs.ruby-lang.org/issues/13551#change-65006 * Author: JustJosh (Joshua Stowers) * Status: Feedback * Priority: Normal * Assignee: * Target version: ---------------------------------------- There doesn't seem to be an intuitive way to alias class methods. Perhaps we can add a method such as ~~~ ruby alias_class_method :new_name, :old_name ~~~ -- https://bugs.ruby-lang.org/