> On 28 Jul 2017, at 17:19, Kwanghoon Choi via swift-evolution > <[email protected]> wrote: > > Hello > > I found someone easy mistake using for in loop statement. > > Ex) > var i = 0 > for i in 0..<10 { } > print(i) > > And this user expected print(i) is “10” > > Many experienced swift developers doesn’t misunderstand like this. But always > someone is new comers, and I think this expression make misunderstand easy > too. > > So why not like this? > > var I = 0 > for 0..<10 { (i) in … } > > I think this is more understandable for loop expression. > > Best Regards > > - Jay Choi
While I sympathise with the intent, I think this is the wrong solution; it would be better to work towards eliminating some of the more common uses of shadowing (e.g- let x = x conditional binding) so that we could justify adding potentially accidental shadowing as a warning instead. Either that or just add shadowing as a warning by default, and maybe make a few exceptions where none will be raised. Personally I avoid single character variable names except where they are part of a formula or such; makes for more verbose code, but that's not necessarily a bad thing, as it's usually clearer exactly what the variables are for as a result, at least when I can think of a good name. _______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
