--cYtjc4pxslFTELvY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Nov 11, 2007 at 07:06:44PM +0900, Jordi wrote: > On Nov 11, 2007 7:01 PM, Matthew Boeh <mboeh / desperance.net> wrote: > > > > On Sun, Nov 11, 2007 at 05:50:18PM +0900, Trans wrote: > > > > > > > > > On Nov 10, 10:55 am, "David A. Black" <dbl... / rubypal.com> wrote: > > > > Hi -- > > > > > > > > I know that a 1.9 feature-freeze is coming soon, but I just wanted to > > > > put in a last-minute plea for some method name changes or removals. > > > > > > > > "invoke_method" is one. I always take the trouble to explain to people > > > > learning Ruby that sending a message and executing a method are not > > > > same thing (even though they often happen together). "send" makes > > > > sense: we're sending the object a message, explicitly. "invoke_method" > > > > does not make sense. We're not invoking a method; we're sending a > > > > message. The object then does something with the method. > > > > > > But is this distiction usable in nay way? Whe do they not coccur > > > together. I'm just curious. I've heard this before, and while I > > > basically understand, I don;t see how it plays out in actual Ruby > > > practice. > > > > > > Thanks, > > > T. > > > > > > > > > > The first thing that comes to mind is method_missing. > > > > ; class Q > > ; def method_missing(meth, *args) > > ; "zzz" > > ; end > > ; end > > ; a = Q.new > > ; a.send(:arbitrary_message) > > # => "zzz" > > ; a.method(:arbitrary_message) > > NameError: undefined method `arbitrary_message' for class `Q' > > from (irb):8:in `method' > > from (irb):8 > > from :0 > > > > Now, whether the distinction is actually significant in any practical sense is > > a different issue. In my experience, it's confusing at first, especially to > > programmers from a procedural background, but it ultimately results in a more > > sophisticated understanding of the object-oriented paradigm. It isn't > > necessarily Ruby's place to fit itself to the task of pedagogy, but I > > personally value the distinction between sending a message to an object > > (Object#send) and invoking one of its methods (Object#method -> Method#call). > > > > -- > > Matthew Boeh > > IIRC, in Ruby everything is message sending to objects even in the > disguise of Object#method, at least conceptually. > Conceptually, yes. But as far as I can tell, Object#respond_to? is effectively equivalent to: def respond_to?(message) !!method(message) rescue false end in that Object#method_missing doesn't have any effect on it. So there is a concrete distinction between messages that map directly to methods and messages handled by method_missing. Actually, in that sense, Object#invoke_method would be an even less semantically correct name if it treats concrete methods and method_missing identically. I'd expect it to behave similarly to Object#method -> Method#call. I'm unfortunately isolated in a terrifying world with no access to Ruby SVN -- can anyone verify whether invoke_method will resolve to method_missing? -- Matthew Boeh --cYtjc4pxslFTELvY Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFHNtmnfi+i1R7d/ZwRAr5YAKCe+OjPExMbjVI/DkrZt9yR1s0YAgCff1DB yXDzWoN7ZGFR+Rghovpt7K4tq -----END PGP SIGNATURE----- --cYtjc4pxslFTELvY--