From: Matthew Kerwin Date: 2013-02-06T13:09:07+09:00 Subject: Re: using an instance variable inside a method --f46d04287a17ba619904d5067c87 Content-Type: text/plain; charset=ISO-8859-1 On 2/5/13 7:59 PM, Matthew Kerwin wrote: > Incidentally, I didn't realise the parser would recognise `price` above > as a function call; I thought lexically it looked like a local variable. > Does the attr_accessor directive make it more clever? Are attributes > lexically different from function calls? Am I overthinking something? On 6 February 2013 12:44, Ryan Victory wrote: > I'm certainly no expert on the Ruby interpreter, however I'd guess that > in order to support monkey-patching, multi file classes, and dynamic > dispatch/metaprogramming, the parser assumes that any part of the code it > can't find at the moment of parsing may be defined somewhere else and > leaves it alone until run time. Just my guess. > Oh of course. If there's no explicit variable creation (price = ...) in the current context, it has to assume it's a function. Don't mind me, carry on. -- Matthew Kerwin, B.Sc (CompSci) (Hons) http://matthew.kerwin.net.au/ ABN: 59-013-727-651 "You'll never find a programming language that frees you from the burden of clarifying your ideas." - xkcd --f46d04287a17ba619904d5067c87 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On 2/5/13 7:59 PM, Matthew Kerwin wrote:
> Incidentally, I didn't realise the parser would recognise `pric= e` above
> as a function call; I thought lexically it looked l= ike a local variable.
> Does the attr_accessor directive make it more clever? =A0Are attr= ibutes
> lexically different from function calls? =A0Am I over= thinking something?

On 6 February 2013 12:44= , Ryan Victory <ryan@raptormail.net> wrote:
=20 =20 =20
I'm certainly no expert on the Ruby interpreter, however I'd gu= ess that in order to support monkey-patching, multi file classes, and dynamic dispatch/metaprogramming, the parser assumes that any part of the code it can't find at the moment of parsing may be defined somewhere else and leaves it alone until run time. Just my guess.

Oh of course. =A0If there's no = explicit variable creation (price =3D ...) in the current context, it has t= o assume it's a function. =A0Don't mind me, carry on.

--
=A0 Matthew Kerwin, B.Sc (CompSci) (Hons)
=A0 http://matthew.kerw= in.net.au/
=A0 ABN: 59-013-727-651

=A0 "You'll never= find a programming language that frees
=A0 you from the burden of clarifying your ideas." - xkcd
--f46d04287a17ba619904d5067c87--