On Wed, 22 Jul 2020 at 12:24, Paul Moore <p.f.moore@gmail.com> wrote:
On Wed, 22 Jul 2020 at 10:54, Stestagg <stestagg@gmail.com> wrote:
>
> I'm (weakly) +1 for the concept of for..else being confusing, weird, and somehow not quite suitable/useful for many use-cases where it feels like it should.
>
> I'm -1 for each of the suggested improvements that I've understood so far.
>
> I agree that the suggested 'ban' on changes in this area is probably not helpful, however it feels like a sloppy way of saying that changes to the syntax are very unlikely to be practical, for a couple of annoying, but important reasons.

I agree that for/while..else is not immediately obvious. But it's
useful in some situations, and it *is* used in real-world code.
agreed.
 
I also agree that all of the proposals I've seen so far are at *least*
as confusing, and would make the situation worse, not better.
Generalising a bit, proposals that suggest *removing* else on loops
are never going to get accepted, because they break existing code for
no clear advantage.
 again, agreed.
Ones that retain else on loops are bad because
they end up providing two (typically equally confusing) ways of doing
things.

I don't think this is the case. I agree that adding an alternative to `else` just to have an alternative is not a good fix, but adding explicit ways to refer to when breaking from the loop would make the use of `else` as it already is clearer.

For example, breaking the change into 2 parts:
1. Adding `elif` to the `for...else` and `while...else` statements seems a logical extension. Guido has even said that the else in loops was invented by reasoning the connection of `if` to `while` (and then `while` to `for`). Perhaps this should be in its own discussion so as not to clutter this thread?
2. Adding a way to use this new `elif` to check the state of the loop. Possibly including if it was broken out of or if it was never entered. Such as having special local variables that are only defined in the block/frame of the loop.


I don't think there's going to be any sort of "ban" on changing
things, but I do think that it's reasonable to point out to people
that all of this discussion is a waste of energy, and a distraction
for people trying to follow this list for proposals that *do* have a
chance of acceptance. The signal to noise ratio on this list can be
bad at the best of times, and dropping ideas that simply won't work
would help everyone. That's not to say that ideas that won't work
aren't welcome - how will anyone learn what's feasible and what isn't
if we shut down well-intentioned proposals? But proposers (and other
participants) also need to accept that pushing an idea that isn't
workable, is unproductive.
 
I agree with you here too, 100%, but it does not feel like we have had said discussion. I would also make the suggestion that surely this thread, although noisey, is the right place to continue the discussion in case a consensus on an approach is reached.

Notice:
This email is confidential and may contain copyright material of members of the Ocado Group. Opinions and views expressed in this message may not necessarily reflect the opinions and views of the members of the Ocado Group.

If you are not the intended recipient, please notify us immediately and delete all copies of this message. Please note that it is your responsibility to scan this message for viruses.

References to the "Ocado Group" are to Ocado Group plc (registered in England and Wales with number 7098618) and its subsidiary undertakings (as that expression is defined in the Companies Act 2006) from time to time. The registered office of Ocado Group plc is Buildings One & Two, Trident Place, Mosquito Way, Hatfield, Hertfordshire, AL10 9UL.