[Swift-devel] multiple declarations of variables.

Mihael Hategan hategan at mcs.anl.gov
Thu Nov 22 13:54:31 CST 2007


On Thu, 2007-11-22 at 19:10 +0000, Ben Clifford wrote:
> At present, the language allows multiple declarations using the same 
> variable name resulting in the second variable shadowing the first.
> 
> eg:
> 
> > file i;
> > file i;
> 
> (which is fairly obvious)
> 
> but also:
> 
> > file foo <"myfile">;
> > file foo = f(x);
> 
> I've seen multiple declarations like this confuse a few people in that 
> past.
> 
> I'd like to make variable shadowing illegal - either of the above should 
> result in a compile time error (or at least a warning).

Error. Even Java and C do that.

> 




More information about the Swift-devel mailing list