Christopher Dicely
4/15/2009 11:49:00 PM
On Wed, Apr 15, 2009 at 3:17 AM, Brian Candler <b.candler@pobox.com> wrote:
>
> There has been no (potential) assignment to y lexically before the puts
> statement, and therefore it is statically decided that y must be a
> method call, i.e. self.y()
>
> This logic may be a little surprising at first, but it means that you
> don't have to declare variables, and it also means you don't have to
> provide an empty set of parentheses when invoking a method which takes
> no arguments.
Well, discussing the issue of determining whether it is a local
variable or method statically at parse time vs. dynamically at run
time, what it means is not so much that but "Ruby runs some amount
faster than it would with dynamic determination". You don't need the
static resolution of method/local variable ambiguity to avoid empty
parens or variable declarations, but static resolution at parse time
makes it quicker than it would be if it was dynamically resolved at
run time.