
On Jan 27, 2016, at 17:06, Steven D'Aprano <steve@pearwood.info> wrote:
On Wed, Jan 27, 2016 at 12:49:12PM -0800, Andrew Barnert via Python-ideas wrote:
The for-loop is a special case, because it assigns a variable in a place where we can't capture it in a let-block. So we introduce a variant:
for let x in things: funcs.append(lambda: process(x))
This reads weird to me. I think it's because I've been spending too much time in Swift, but I also think Swift may have gotten things right here, so that's not totally irrelevant.
It reads weird to me too, because "for let x in ..." is just weird. It's uncanny valley for English grammar: at first glance it looks like valid grammar, but it's not.
Ah, good point.
[...]
As I've mentioned before, both C# and Ruby made breaking changes from the Python behavior to the Swift behavior, because they couldn't find any legitimate code that would be broken by that change.
I'm not sure if you intended this or not, but that sounds like "they found plenty of code that would break, but decided it wasn't legitimate so they didn't care".
:) What I meant is they found a small number of examples of code that would be affected, but all of them were clearly bugs, and therefore not legitimate. Obviously that can be a judgment call, but usually it's a pretty easy one. Like the function that creates N callbacks that all use the last name, instead of creating one callback for each name, preceded by this comment: # Don't call this function! Ruby sucks but when I complain they tell me I'm too dumb to fix it so just don't use it!!!! Whether the 1.9 change fixed that function or re-broke it differently scarcely matters; clearly no one was depending on the old behavior. Maybe Python is different, and we would find code that really _does_ need 10 separate functions that all compute x**9 or that all disable the last button or... well, probably something more useful than that, which I can't guess in advance. I certainly wouldn't suggest just changing Python based on the results of a search of Ruby code! But I would definitely suggest doing a similar search of Python code before giving people two similar but different statements to hang themselves with.