From: Chad Perrin Date: 2011-04-29T05:22:23+09:00 Subject: Re: Is everything object ? --tThc/1wpZn/ma/RB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Apr 29, 2011 at 02:23:32AM +0900, Josh Cheek wrote: > On Thu, Apr 28, 2011 at 10:12 AM, Chad Perrin wrote: > >=20 > > I'm a little curious about why, to you, boolean methods are "relevant" > > and other methods are not. For that explanation, I would have just said > > that methods are not objects -- rather than saying something like > > "boolean methods aren't objects; let's not talk about other methods > > (which also aren't, but we shouldn't say that)". > > Sorry, I wasn't very clear, it's a difficult subject to talk about > because the language is largely ambiguous. >=20 > Apparently, methods are *technically* not objects. Roger already > brought it up above, and it's been discussed before > (http://www.ruby-forum.com/topic/424911). Now, given that we can > request a method, and get an instance of Method, lets disregard this as > it seems to me to be an implementation detail. >=20 > So we can say that methods are objects, and everything suddenly makes > sense again. Operators are methods, and methods are objects, so > operators are objects. Except for boolean operators, which are not > methods and thus not objects. They are basically keywords. Here are > some examples: Oh, you're talking about boolean operators. I thought you were talking about actual boolean *methods*: irb(main):001:0> foo =3D Hash.new =3D> {} irb(main):002:0> foo.empty? =3D> true =2E . . but I dispute the argument you present that methods are objects. The fact that one can wrap a method in a "method object" does not make the method *itself* an object; it just creates an object that has a particular kind of interface to the method. >=20 > You can't request them as methods, and thus can't pass them as > arguments or put them into block slots or store them in variables. > true.method '&' # =3D> # true.method '&&' # ~> > -:1:in `method': undefined method `&&' for class `TrueClass' > (NameError) Yeah -- that's because they aren't methods. They're more like punctuation. --=20 Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --tThc/1wpZn/ma/RB Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAk25xewACgkQ9mn/Pj01uKXahQCfdLFnqU84OiQk5fJxPKp/yhwP UHoAoIZoZ1bzDYT8JGjum+qZvefIvE5a =/PEJ -----END PGP SIGNATURE----- --tThc/1wpZn/ma/RB--