From: "David A. Black" Date: 2007-11-07T21:55:08+09:00 Subject: Re: invoke_method, and things you "just have to know" Hi -- On Wed, 7 Nov 2007, Paul Brannan wrote: > On Wed, Nov 07, 2007 at 07:23:09PM +0900, David A. Black wrote: >> Hi -- >> >> I see that send! is gone from 1.9, and send is back to calling private >> methods. OK... but there's now also invoke_method, which doesn't call >> private methods if it has an explicit receiver but does if it doesn't. >> >> My concern is that this is one of those things where you "just have to >> know" which is which. It's like instance_eval and instance_exec: the >> method names themselves don't tell you how they differ, so you just >> have to memorize which one does what. > > I disagree. When I see the name "invoke_method" I expect it to use the > normal method invocation mechanism, so the behavior you described makes > sense. On the other hand, "send" doesn't tell me what it does (but > primarily because I come from a C++ background where there is no concept > of sending messages to objects). However, having "send" work the way it > has worked for years does make sense to me. > > I could probably argue the other side as well, but I'll let you take > that job. :) I think a lot about what's involved in teaching people Ruby -- which, I hasten to add, is very different from the "Let's do X because it will make people from Language L feel at home...." In other words, I don't want Ruby to target beginners, but I do think the experience of beginners is an important measurement and reality check. I find it harder to explain send/invoke_method, as to their differences, than send/send! (once the concepts of private methods and dangerous variants of methods has been grasped). It's partly the near-total isolation of "invoke" from any other terminology ever used in or, usually, around Ruby. "Invoke" is (more or less) "call", translated into Latin. So, if nothing else, I'd like to see it called "call_method". If it's calling a method, then it should have the simplest name. The other thing I dislike about it, though, is that it conceals the double articulation: sending a message to an object, and having the object execute a method (or not). Of course, sending a message usually leads to executing a method, but I still prefer send/send! because what one is really doing is sending a message. How that message is handled is a secondary thing. Anyway, "call_method" would be better than "invoke_method". David -- Upcoming training by David A. Black/Ruby Power and Light, LLC: * Advancing With Rails, Edison, NJ, November 6-9 * Advancing With Rails, Berlin, Germany, November 19-22 * Intro to Rails, London, UK, December 3-6 (by Skills Matter) See http://www.rubypal.com for details!