> In Perl 6 a lexical variable is scoped to the block in which it's
declared.
> Since C<$cond> is declared in the block *containing* the C<while> and
C<else>,
> it's scoped to that block. So you can use it inside the C<while>'s block,
> inside the C<else>'s block (assuming Larry allows such a construct), and
in
> the following C<print> statement.

OK, will at least this statement still work as it does in Perl5?  Notice
addition of parens.

  use strict;
  ...

  while (my $result = blah() ) {
      ...
  }

  print $result, "\n";

i.e., $result is scoped to each iteration of the while loop, and the
compiler crashes on the last line because $result isn't my'ed.

If that changes, I for one will need to go rewrite virtually every script
and library I maintain, not to mention changing my coding style to something
more Java-like in its inconenience.  My personal pain aside, it seems
counter-intuitive to me.  $result gets my'ed over and over and over.  In my
world view that should result in a warning about declaring the same variable
twice in the same scope.

Even if the addition of the parens does make a difference, it doesn't look
quite logical to me.  Parens in an evaluation are just grouping mechanisms,
not structural controls.  $me && $you  is the same as ($me && you).  So the
addition of parens in the example above looks like just a redundant
indication of grouping, not a declaration of a change in scoping rules.

-Miko

Reply via email to