So, please change S04 as discussed.
Thanks
Stefan
---------------------------------
Expecting? Get great news right away with email Auto-Check.
Try the Yahoo! Mail Beta.
I, too, would like to point to this as an important issue. It would be
nice if someone could point to a good reason to change this behavior
from the one in Perl 5. I might be all wrong in my reasons to be
horrified at the following:
my $foo;
# ...later in the same scope...
my $foo; # illegal Perl5, legal Perl6
But if I am, I would like to know why. Perl6 is strict in not letting
the programmer declare a variable less then once, why shouldn't it be
strict in not letting them declare it more than once?
--
masak
No, that's perfectly legal in perl5; it just generates a warning:
use warnings;
my $x = 1;
my $f1 = sub { $x };
my $x = 2;
my $f2 = sub { $x };
printf "f1=%d f2=%d x=%d\n", $f1->(), $f2->(), $x;
which gives
$ perl588 /tmp/p
"my" variable $x masks earlier declaration in same scope at /tmp/p line 6.
f1=1 f2=2 x=2
--
But Pity stayed his hand. "It's a pity I've run out of bullets",
he thought. -- "Bored of the Rings"
Ah, your quite right. Going back, I see that this was indeed pointed
out in the original thread as well; I just didn't catch it then.
FWIW, I think a warning is fine. (Because in my world a warning means
that something isn't "perfectly legal".) Maybe it's in line with
Perl's policy of being forgiving when possible to give a warning
instead of a compile-time error. That's fine.
What bothers me is that one might not even get a warning in Perl 6.
Since a duplicated variable declaration is often due to programmer
confusion, it seems like we're passing up such a fine opportunity for
telling them about it. What underlying design decision is it that
prevents us from giving a warning here, as in Perl 5?
Pugs currently executes the above code and gives the same output, but
no warning:
$ pugs test.pl
f1=2 f2=2 x=2
// Carl
> my $foo;
> # ...later in the same scope...
> my $foo; # illegal Perl5, legal Perl6
That isn't illegal in Perl 5. It yields the warning:
"my" variable $foo masks earlier declaration in same scope
but it does work.
Smylers