From: Eric Christopherson Date: 2010-10-14T09:51:19+09:00 Subject: Re: Why does a lot of code not include parenthesis? On Tue, Oct 12, 2010 at 6:20 PM, David Masover wrote: > On Monday, October 11, 2010 09:58:40 pm ara.t.howard wrote: >> the only real argument for requiring parens is so that >> >>   o.foo  # returns the method foo >> >> as in javascript.  other arguments are mostly religious. > > I actually really like this about JavaScript, but as it turns out, JavaScript > has getters and setters. I'm guessing they've been added to the language > itself because they pretty much always existed as part of the browser's API -- > think "location.href = foo" -- so it makes sense to expose them to developers. > > So here, the only real question is whether it's more common to want to deal > with methods directly this way, or to want to refactor instance variables into > methods. I like that Ruby's approach has everything entirely encapsulated by > default -- attr_accessor means I always have the option to replace an instance > variable with a pair of methods. True, I have setters and getters in > JavaScript, but they're the default in Ruby. 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.)