why no break N levels, as in other leading languages?

Simon Brunning SBrunning at trisystems.co.uk
Fri May 2 11:56:28 EDT 2003


> From:	Evan Simpson [SMTP:evan at 4-am.com]
> This reminds me of a proposal that I actually coded up a Python patch 
> for, then lost:
> 
> http://groups.google.com/groups?threadm=CXxz3.57%242y4.69103%40news-dal.co
> rridex.com
> 
> It allowed the above to be written as:
> 
> try:
>      for i in range(foo):
>          for j in range(bar):
>              for k in range(spam):
>                  if my_func():
>                      break 'Matched'
> continue 'Matched':
>      pass
> 
> This is more than syntactic sugar, since the association between the 
> break statement and the continue clause is completely lexical and static.
> 
> I realize that the 'continue' keyword syntax for the break target isn't 
> great, but I couldn't think of a better one.
 
How about:

try:
     for i in range(foo):
         for j in range(bar):
             for k in range(spam):
                 if my_func():
                     goto 'Matched'
tag 'Matched':
     pass

;-)

Simon B.
--LongSig




-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.





More information about the Python-list mailing list