On Fri, 27 Nov 2020 18:32:54 +1300 Greg Ewing email@example.com 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.
I'm not a native English speaker, but for me, "for let something in sequence" doesn't sound too bad. If spoken as a natural language, it would need intonation and pauses, something like:
"for... let something be each element in sequence ... repeat ..."
And mind that "for let" was a "draft" proposal in my initial post, immediately replaced by "for const", which exactly both readable and intuitive for what it does (e.g. the fact that it uses/passes variable(s) by value, so no cells are needed).
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.
When I wrote about it, my mental model was that "for let" or "for const" is an atomic syntactic construct akin to "async for". I also would like to remind that the backing idea behind both is that they introduce a new block scope ;-). Then it's clear that their arguments can be only bare variable names ("for let stuff[k] in ..." is a syntax error, there's normal "for stuff[k] in ..." remains for that).
And both "for let" and "for const" are clearly not needed, and between them, "for const" is much better. (But "let" can be useful in other places, ditto for "const").