On Tue, Oct 12, 2010 at 6:20 PM, David Masover <ninja / slaphack.com> wrote:
> On Monday, October 11, 2010 09:58:40 pm ara.t.howard wrote:
>> the only real argument for requiring parens is so that
>>
>> =A0 o.foo =A0# returns the method foo
>>
>> as in javascript. =A0other arguments are mostly religious.
>
> I actually really like this about JavaScript, but as it turns out, JavaSc=
ript
> 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 A=
PI --
> think "location.href =3D foo" -- so it makes sense to expose them to deve=
lopers.
>
> So here, the only real question is whether it's more common to want to de=
al
> 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 ins=
tance
> 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.)