--l76fUT7nc3MelDdI Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Oct 15, 2010 at 07:28:16AM +0900, Eric Christopherson wrote: > On Thu, Oct 14, 2010 at 10:22 AM, Chad Perrin <code / apotheon.net> wrote: > > On Thu, Oct 14, 2010 at 09:51:19AM +0900, Eric Christopherson wrote: > >> > >> I'm not sure I follow. It sounds like you're saying that the > >> expression "o.foo" can mean either "invoke method foo on object o" or > >> "instance variable foo of object o", depending on how o is defined. > >> But AIUI "o.foo" can only ever mean the former. (That method might be > >> an accessor for an instance variable, but you still can't refer to an > >> instance variable directly using dot notation.) > > > > This is true but, to be fair, it can look an awful lot like direct access > > to the variable: > > > > class Foo > > def initialize(foo=nil) > > @foo = foo > > end > > attr_accessor :foo > > end > > > nil > > o = Foo.new > > > #<Foo:0x2854ec78 @foo=nil> > > o.foo = 'foo' > > > "foo" > > puts o.foo > > ¨Âïï > > > nil > > Right, but I don't see what it has to do with the optionality of > parentheses. The point made earlier (one I'd seen before) was that the > optionality of parentheses made refactoring easy. I think David Masover's response of 15 October answers this question of yours, so I'll let that message speak for the matter of the optionality of parentheses help with refactoring. I'll just offer this oversimplified summary: When you do not need to differentiate between a call to what amounts to an instance variable and a call to a method that returns the value of an instance variable by using parentheses, swapping out the back end of that call does not require changing the syntax of all relevant calls. In short, it doesn't change the behind-the-scenes work done to refactor your code, but it changes the "superficial" work that has to be done because the call changed from (in effect) a straightforward variable evaluation to a method call that returns the value of that variable, or vice versa. -- Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --l76fUT7nc3MelDdI Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAky+iNgACgkQ9mn/Pj01uKVC3wCgsg5Ihyw2jh95WpR8uDdyDf9U xN4AoL/y0qKto1ILt0HpRu9XeI5IOQEO HI -----END PGP SIGNATURE----- --l76fUT7nc3MelDdI--