From: Matthew Boeh Date: 2007-11-11T19:29:56+09:00 Subject: Re: method names in 1.9 --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 wrote: > > > > On Sun, Nov 11, 2007 at 05:50:18PM +0900, Trans wrote: > > > > > > > > > On Nov 10, 10:55 am, "David A. Black" 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 peo= ple > > > > 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_meth= od" > > > > 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 =3D Q.new > > ; a.send(:arbitrary_message) > > # =3D> "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 s= ense is > > a different issue. In my experience, it's confusing at first, especiall= y 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 >=20 > IIRC, in Ruby everything is message sending to objects even in the > disguise of Object#method, at least conceptually. >=20 Conceptually, yes. But as far as I can tell, Object#respond_to? is effectiv= ely=20 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= =20 concrete distinction between messages that map directly to methods and=20 messages handled by method_missing. Actually, in that sense, Object#invoke_method would be an even less=20 semantically correct name if it treats concrete methods and method_missing= =20 identically. I'd expect it to behave similarly to Object#method ->=20 Method#call. I'm unfortunately isolated in a terrifying world with no acces= s=20 to Ruby SVN -- can anyone verify whether invoke_method will resolve to=20 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+Rghovpt7K4= =LBtq -----END PGP SIGNATURE----- --cYtjc4pxslFTELvY--