[Python-ideas] Loop labels

Matt Joiner anacrolix at gmail.com
Thu Mar 8 20:14:12 CET 2012


On Mar 9, 2012 3:04 AM, "Simon Sapin" <simon.sapin at kozea.fr> wrote:
>
> Le 08/03/2012 19:52, Matt Joiner a écrit :
>
>> Allow for and while statements to be labelled using "as".
>
>
> I like the idea. But regardless of whether it should be added at all, I
see one issue with the proposition in its current form.
>
> The with statement has a variable name after its own "as" keyword. Do
loop labels live in the same namespace as variables? Or can I have a
variable with the same name as a loop label without the two interfering?

The with statement is not a loop statement and would not be extended, so
this is not an issue.

It would be nonsensical to assign to loop labels, so I figure there would
be some non trivial checks done when a function is compiled. You raise an
interesting point.

>
> Regards,
> --
> Simon Sapin
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas

I neglected to mention that nested looping often requires a lot of
undesirable temporaries and additional state checks. Avoiding this a very
common goal, that can be circumvented with the aforementioned constructs.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20120309/4c1a3947/attachment.html>


More information about the Python-ideas mailing list