From: Chad Perrin Date: 2010-11-14T08:03:07+09:00 Subject: Re: what's an object? --ew6BAiZeqk4r7MaW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Nov 13, 2010 at 03:23:13PM +0900, Josh Cheek wrote: > On Fri, Nov 12, 2010 at 10:35 PM, Chad Perrin wrote: >=20 > > > > Why should you be able to do puts(3), if you think we should not be able > > to do foo(3)? > > > > > Because puts(3) is shorthand for "send the object 'Kernel' the message > 'puts' with the parameter '3'" but foo(3) is shorthand for "send the obje= ct > 'foo' no message at all with the argument 3" That doesn't work because it= is > not consistent with Ruby's object model. >=20 > In other words, the difference is this: >=20 > Kernel.send "puts" , 3 > foo.send "" , 3 The claim was that foo is just the "object" puts, though, which means that should actually look like this: Kernel.send "puts" , 3 Kernel.send "foo" , 3 =2E . . if the method and the object are the same thing. The fact they don't work that way just shows that they method and the object are *not* the same thing -- that the method puts is *not* an object as claimed. >=20 > They may look the same the way you formatted their syntax, but they are > completely different. The fact they are completely different is my point. One is an object. The other is a method. Ne'er the twain shall meet. >=20 > Putting (3) after puts is not what invoked it. Sending it to the object > Kernel is what invoked it. Likewise, putting (3) after foo will not invoke > foo, rather, sending call to the object foo will invoke it. I can't think= of > any way to reconcile such a belief with anything anywhere in Ruby, and yo= ur > puts example only appears to be an exception because you formatted it > deceptively. I don't even know what you're trying to say here that disagrees with anything I was saying. My question was rhetorical, because I already knew (and was making the point) that foo (the object) and puts (the method) are not the same thing. >=20 > From your table, its not that puts.call(3) and foo(3) fail to work, its t= hat > they don't even make sense. puts is invoked, it returns a value. You aren= 't > sending call to puts, you are sending it to nil, the object that puts > returns. You are just using tricks of syntax to be ambiguous. Make > it Kernel.puts().call(3) and it is explicit. Make it self.foo(3) and it is > explicit, it is a message to self, not to foo. Of course, they don't make sense. That's my point. One is a method, the other an object. If the method *was* an object, you'd be able to send it messages to invoke methods. You can't -- as you pointed out. Thank you for making my point for me. --=20 Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --ew6BAiZeqk4r7MaW Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAkzfF7EACgkQ9mn/Pj01uKVqaQCffnF531scYtrNLmtxR1NJmuHb FcAAnRBU6lKjmZgXAPpSxpNQoMU95s0R =QsYY -----END PGP SIGNATURE----- --ew6BAiZeqk4r7MaW--