On Fri, Nov 27, 2020 at 4:34 PM Greg Ewing firstname.lastname@example.org wrote:
On 27/11/20 1:23 pm, Chris Angelico wrote:
That makes no sense as a phrase in English.
Nor do lots of other constructs when they get combined. English doesn't really have good parallels for most computing concepts.
Python manages to not be wildly ungrammatical with the bits of English that it borrows, though.
How will this "new assignment target" work with different forms of assignment targets? For instance:
for let k, stuff[k] in d.items(): ...
I was thinking it could only be put before a bare name and would only apply to that name. So if there are multiple targets in the assignment, you would need to mark each one that you want treated.
That'd be my expectation, too. Which would mean you could have:
for k, let v in d.items()
As such, I don't think it needs to be read as "for let". It's more "let v". Maybe I'm weird for having spent a lot of time writing "for (int i = 0; i < n; ++i)" in C++, but I don't see inline variable tags as being overly problematic :)
But if it can be done in the loop header, and it's actually a part of the assignment part (rather than being a keyword applying to the entire loop), there's going to be people expecting to be able to do this:
for let i in collections.Counter(): let val = input("> ") def foo(): print(i, val) functions.append(foo)
where the "let" could be equivalently applied to ANY variable name or assignment. IMO that will need to be addressed in the PEP (either for or against, but not silent).