[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

Re: [ID 20000122.001] Incorrect scoping of if(){}else{}



On Sat, Jan 22, 2000 at 02:25:00PM +0000, M.J.T. Guy wrote:
> 	if (my $x = 1, 0) {
> 	    my $x = 2;
> 	} else {
> 	    my $x = 3;
> 	}
> 
> produces spurious warnings
> 
> "my" variable $x masks earlier declaration in same scope at - line 2.
> "my" variable $x masks earlier declaration in same scope at - line 4.

The only reason why I would use if (my $x = 1, 0) is precisely to get it
scoped like perl seems to do here. That is: I expect to be able to see
$x in both the "if" and the "else" branch, but not outside of them.

-- 
The idea is that the first face shown to people is one they can readily
accept - a more traditional logo. The lunacy element is only revealed
subsequently, via the LunaDude. [excerpted from the Lunatech Identity Manual]


Follow-Ups from:
Larry Wall <larry@wall.org>
References to:
"M.J.T. Guy" <mjtg@cus.cam.ac.uk>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]