--Apple-Mail-6--498786687
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset-ascii


On Jun 15, 2011, at 5:00 PM, Ilias Lazaridis wrote:
> 
> I don't understand, why "p $xx" does not fail with and "not defined"
> error.

Because the parser 'sees' the variable $xx and defines it before "p $xx" gets executed.

This behavior is different than the local variable case because global variables can be discovered by their name alone (i.e. they start with '$').  This is a syntactic property that the parser can take advantage of.  That property doesn't exist for local variables because, in some contexts, they are indistinguishable syntactically from a zero-argument method call.  Consider these examples separately and not as part of a single snippet of code:

  a = b    # 'a' is clearly a local variable while 'b' could be a local variable or a zero-argument method call

  c = d()  # 'd()' is clearly a zero-argument method call and *not* a local variable, 'c' is a local variable

  do_something_with(x,y,z)     # x,y, and z could be method calls or variables


Gary Wright-Apple-Mail-6--498786687--