On Sat, Dec 5, 2020 at 11:05 AM Alexis Masson <a.masson...@ntymail.com>
wrote:

> I agree with you that the point of `break x` — labeled or numbered — is to
> target a specific loop to "jump" to, but I'm not comfortable with
> introducing labels to Python. The reason for this is that they look too
> much like identifiers, and should, therefore, be bound to *something*,
> following Python's motto of "everything is an object". I don't see what
> kind of an object could be bound to that, what kind of API it would expose,
> how it could be manipulated/re-affected, it behavior out of the loop…
>

I don't really care how the labels are spelled, just that they are spelled
on the line that defines the loop.  For example:

while not processed() as 1:
    for x in the_stuff as 37:
        if all_done(x):
            break 1

Numbers like 1 and 37 are pretty clearly not binding targets.  By
convention, using numbers 1, 2, 3, 4 for successive levels might be good.
But it wouldn't break directly if you added or removed a nested loop as
long as you kept its number.  That said, allowing slightly more descriptive
names than "2" seems sorta nice.  Using sigils to make it "obviously not a
binding target" is way too much ugly for the limited need.

I don't think this feels Pythonic, but if the labels were exclusively
one-digit positive integers, that would limit named loop depth to 9.  That
is a good thing.  Anything over 4 levels is questionable, anything over 6
is monstrous.  So that's extra leeway for anything that is actually a good
idea.  But I think "use a natural number" and rely on "we're all adults
here" is more likely to fit in Python.


-- 
The dead increasingly dominate and strangle both the living and the
not-yet born.  Vampiric capital and undead corporate persons abuse
the lives and control the thoughts of homo faber. Ideas, once born,
become abortifacients against new conceptions.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/QRJ635HZEO4UJX5RARWJC55J776XJJSZ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to