Sorry for all the individual messages here. Let me take a last whack at
this:
> Now what if you leave out the declaration? Then Perl can generate a
> warning about the $myint in the inner scope shadowing the $myint in
> the outer scope. This is what C does. I think that this has proven
> to be a successful solution for C. It might work well for Perl also.
No, I don't think this is a good idea. I think if someone writes code
like this:
if (condition) {
$switch = 1;
}
# ...
print "$something" if $switch;
This should do what is intended, without the my()'s. I don't think
making this harder to do has any benefit.
> You said it would necessarily be strange and obfuscated, and I don't
> think this situation would be either strange or obfuscated.
If it's the above example, I think it's both. Definitely. If I was any
level Perl programmer looking at this, I would be incredibly confused at
what's going on.
Remember, *many* Perl programmers don't know C. I'm a novice C
programmer at best.
> If you want something a little stranger though, here is another idea:
> The compiler could see that you used the same variable name in the
> inner and in the outer block, and infer the `my' declaration at the
> top of the outer block, just as if you had put it there yourself.
This is the idea that I think could warrant an RFC. If we did this
right, it would be really cool.
However, I'm firmly against the other suggestions you have. I think we
should either keep Perl the way it is, or make it so that the variables
are *correctly* lexically scoped without the my()'s, but I do *NOT*
think in any way that default Perl 6 should ever require a my().
-Nate