Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

The autodecrement is not magical. -- Larry Wall in the perl man page


devel / comp.lang.python / RE: Friday Finking: Contorted loops

SubjectAuthor
* Re: Friday Finking: Contorted loopsTerry Reedy
`* Re: Friday Finking: Contorted loopsGreg Ewing
 `- RE: Friday Finking: Contorted loopsAvi Gross

1
Re: Friday Finking: Contorted loops

<mailman.679.1631235193.4164.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=15081&group=comp.lang.python#15081

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: tjre...@udel.edu (Terry Reedy)
Newsgroups: comp.lang.python
Subject: Re: Friday Finking: Contorted loops
Date: Thu, 9 Sep 2021 19:47:10 -0400
Lines: 49
Message-ID: <mailman.679.1631235193.4164.python-list@python.org>
References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<she6e0$3bi$1@ciao.gmane.io>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de mkckX/p3bNO0OiQqwkRXKwsn5rCAzQ4xy6DemP68Lyfw==
Return-Path: <python-python-list@m.gmane-mx.org>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.016
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'loop': 0.07; 'loops.':
0.07; 'pep': 0.07; 'message-id:@ciao.gmane.io': 0.09;
'received:ciao.gmane.io': 0.09; 'received:gmane.io': 0.09;
'received:list': 0.09; 'terry': 0.09; 'case:': 0.16;
'from:addr:udel.edu': 0.16; 'idle,': 0.16; 'loops': 0.16;
'matched': 0.16; 'received:116.202': 0.16; 'received:116.202.254':
0.16; 'received:116.202.254.214': 0.16; 'useful.': 0.16; 'wrote:':
0.16; 'that.': 0.16; 'python': 0.16; 'uses': 0.19; 'pm,': 0.20;
'to:addr:python-list': 0.23; 'code': 0.24; '>>>': 0.26; 'suspect':
0.27; 'bit': 0.28; 'header:User-Agent:1': 0.31; 'there': 0.31;
'but': 0.31; 'context': 0.32; 'keyword': 0.32; 'needed.': 0.32;
'python-list': 0.32; 'header:In-Reply-To:1': 0.33; 'running':
0.35; 'case.': 0.35; 'cases': 0.37; 'special': 0.37; 'word': 0.38;
'does': 0.38; 'include': 0.40; 'least': 0.40; 'could': 0.40;
'common': 0.60; 'covered': 0.61; 'cost': 0.64; 'above': 0.65;
'less': 0.68; 'order': 0.68; 'latter': 0.69; 'above,': 0.71;
'received:116': 0.71; '1.0': 0.77; '....': 0.81; 'benefit.': 0.84;
'rare': 0.84; 'sometime': 0.91; 'dependent': 0.93; 'keywords':
0.95
X-Injected-Via-Gmane: http://gmane.org/
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
In-Reply-To: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
Content-Language: en-US
X-Mailman-Approved-At: Thu, 09 Sep 2021 20:53:11 -0400
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <she6e0$3bi$1@ciao.gmane.io>
X-Mailman-Original-References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
 by: Terry Reedy - Thu, 9 Sep 2021 23:47 UTC

On 9/9/2021 5:36 PM, dn via Python-list wrote:
> Why does Python not have a repeat-until loop construct?

1. It is not needed. You covered that.

2. It is rare useful. For loops are common. While loops are occasional
(nearly an order of magnitude less common than for loops. Fractional
loop constructs are rare. ("loop-and-a-half" is a mislabel since at not
even one loop is guaranteed.) "do-while" or "repeat-until is even rarer
since fractional-loop include this as a special case.

3. Adding 'until' as a keyword *now*, rather than in 1.0 or at least
several versions ago, has cost so far judged to outweigh the small
benefit. The PEP parser makes contextual keywords much more easily
possible but there is a cost to having a context dependent grammar.
Consider this 3.10.0 snippet:

>>> match, case = 1, 1
>>> match match:
.... case case:
.... print('matched')
....
....
matched
>>> match case:
.... case match:
.... print('matched')
....
....
matched

To me, having a word sometimes be a keyword and sometime not make code
harder to read. In IDLE, it is a bit easier as the keyword uses of
'match' and 'case' above are correctly highlighted as keywords, and the
non-keywords uses not highlighted. But this is harder that for
full-time keywords with sane code that works in an re-based highlighter.

Underscore, not used above, but also a new contextual keyword, is even
harder. Three of us could not get all the cases we tested correct and I
suspect doing so without running the PEG parser may be impossible.
Since highlighting is redone with each keystroke, I suspect doing the
latter would add a noticeable and unacceptable lag between keystrokes
and display.

--
Terry Jan Reedy

Re: Friday Finking: Contorted loops

<iq0ctvF77tU1@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=15086&group=comp.lang.python#15086

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: greg.ew...@canterbury.ac.nz (Greg Ewing)
Newsgroups: comp.lang.python
Subject: Re: Friday Finking: Contorted loops
Date: Fri, 10 Sep 2021 18:39:57 +1200
Lines: 17
Message-ID: <iq0ctvF77tU1@mid.individual.net>
References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<she6e0$3bi$1@ciao.gmane.io>
<mailman.679.1631235193.4164.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net fBV0cLLgMOck4PgAUWw/mQ7d270HoYPa+dlAV9ZLTd3yCZFH54
Cancel-Lock: sha1:IJkinApWe/lvXMWTi1wNg/RQnUs=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:78.0)
Gecko/20100101 Thunderbird/78.4.0
In-Reply-To: <mailman.679.1631235193.4164.python-list@python.org>
Content-Language: en-US
 by: Greg Ewing - Fri, 10 Sep 2021 06:39 UTC

On 10/09/21 11:47 am, Terry Reedy wrote:
> 2. It is rare useful.  For loops are common.  While loops are occasional
> (nearly an order of magnitude less common than for loops.  Fractional
> loop constructs are rare.

I would say that fractional loops are more common than loops
which truly need to execute completely at least once, and
aren't bugs waiting to be triggered by an edge case such as
empty input.

I seem to remember someone - maybe Wirth? - long ago expressing
the opinion that repeat-until loops often tended to be error
prone, but I can't provide a reference, sorry.

--
Greg

RE: Friday Finking: Contorted loops

<mailman.689.1631309788.4164.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=15099&group=comp.lang.python#15099

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: avigr...@verizon.net (Avi Gross)
Newsgroups: comp.lang.python
Subject: RE: Friday Finking: Contorted loops
Date: Fri, 10 Sep 2021 17:36:22 -0400
Lines: 86
Message-ID: <mailman.689.1631309788.4164.python-list@python.org>
References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<she6e0$3bi$1@ciao.gmane.io>
<mailman.679.1631235193.4164.python-list@python.org>
<iq0ctvF77tU1@mid.individual.net>
<026001d7a68b$e6865ff0$b3931fd0$@verizon.net>
Mime-Version: 1.0
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de 5FNBA9TjWHdYj5W12t+ThgJydK7vxSbL4UlmTX8S27NQ==
Return-Path: <avigross@verizon.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=verizon.net header.i=@verizon.net header.b=BUf9BAwA;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.023
X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'parallel': 0.05; 'thread':
0.05; 'variable': 0.05; 'exit': 0.07; 'loop': 0.07; 'loops.':
0.07; 'code?': 0.09; 'fail.': 0.09; 'terry': 0.09; 'threads':
0.09; 'url:mailman': 0.15; 'algorithms': 0.16; 'bugs': 0.16;
'condition.': 0.16; 'controlling': 0.16; 'false.': 0.16; 'greg':
0.16; 'guarantees': 0.16; 'input.': 0.16; 'loops': 0.16;
'mentioned,': 0.16; 'picking': 0.16; 'received:(vzm hermes smtp
server)': 0.16; 'reference,': 0.16; 'repeated': 0.16; 'setup,':
0.16; 'sorry.': 0.16; 'specified,': 0.16; 'specify': 0.16;
'starting.': 0.16; 'top,': 0.16; 'triggered': 0.16; 'useful.':
0.16; 'wrote:': 0.16; "can't": 0.17; "aren't": 0.19; 'to:addr
:python-list': 0.20; 'language': 0.21; 'languages': 0.22; 'maybe':
0.22; 'code': 0.23; 'idea': 0.24; 'skip:- 10': 0.25; 'url-
ip:188.166.95.178/32': 0.25; 'url-ip:188.166.95/24': 0.25;
'section': 0.25; 'url:listinfo': 0.25; 'programming': 0.25; 'url-
ip:188.166/16': 0.25; 'friday,': 0.26; 'else': 0.27; 'bit': 0.27;
'sense': 0.28; 'it,': 0.29; 'error': 0.29; 'seem': 0.31; 'am,':
0.31; 'wide': 0.31; 'url-ip:188/8': 0.31; 'program': 0.31;
'think': 0.32; 'empty': 0.32; 'end.': 0.32; 'friday': 0.32;
'half': 0.32; 'python-list': 0.32; 'specified': 0.32; 'but': 0.32;
'there': 0.33; 'someone': 0.34; 'able': 0.34; 'mean': 0.34;
'header:In-Reply-To:1': 0.34; 'trying': 0.35; 'handling': 0.35;
'runs': 0.35; 'functions': 0.36; 'people': 0.36; 'necessarily':
0.37; 'others': 0.37; 'way': 0.38; 'read': 0.38; 'quite': 0.39;
'least': 0.39; 'single': 0.39; 'ago': 0.39; 'use': 0.39; 'break':
0.39; 'still': 0.40; 'forms': 0.40; 'something': 0.40; 'want':
0.40; 'provide': 0.60; '10,': 0.61; 'remember': 0.61; 'here.':
0.61; 'from:': 0.62; 'to:': 0.62; 'seen': 0.62; 'forward': 0.62;
'finally': 0.62; 'true': 0.63; 'simply': 0.63; 'becomes': 0.64;
'opinion': 0.64; 'overall': 0.64; 're:': 0.64;
'received:74.6.135': 0.64; 'remains': 0.64; 'your': 0.64; 'look':
0.65; 'less': 0.65; 'areas': 0.67; 'bad': 0.67; 'order': 0.69;
'enclosed': 0.69; 'shape': 0.69; 'within': 0.69; 'conditions':
0.70; 'truly': 0.70; '2021': 0.71; 'waiting': 0.73; 'sent:': 0.78;
'extra': 0.84; 'happens': 0.84; 'disagree': 0.84; 'entered': 0.84;
'interpreting': 0.84; 'killed': 0.84; 'manipulated': 0.84;
'outsiders': 0.84; 'perspective,': 0.84; 'rare': 0.84; 'weird':
0.84; 'keywords': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verizon.net; s=a2048;
t=1631309785; bh=Eo9/Zvo1Lqs/sMylPfF0kyRmzDXo2FTB4UUY9n0FZlo=;
h=From:To:References:In-Reply-To:Subject:Date:From:Subject:Reply-To;
b=BUf9BAwAxw3CEaw7zeu8fZGm5WAMUHZW105c/sgHEWHcErsxvDpYMufLl0R++P29eB0QUiozWW0UY9cCpZ6X3xmxDJvhfoJ0+uRnhKoMtyLPRkLDsPt2CNPpJ9iyxj0Zb5FXXbIz+3CNZfjfSN9QMq6MJzvxwBbkEYq/wnTdZignk/l/MeTzi8dum93pA0gX0rD6/GoIZEACEx4ux8EkJ/A38SvzYJ0bsvGH4PVB/NAh8ynh8UfrXii0f5lMyoTNjJYtTV3cefixyS1VgYCG4i09Z8hHYWsyzAmi03eHewsz3fwE+4cls91JrS2t5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J6a3ZeUey4BGZRKw
gK82RTYGeUnwVtD3K9vtv5iYtRcHXJxH0c61HqxxzBkfMWD1o01X3pIT23OsybvuiZzlGoOtrtYQ
RrLDhKstpD9zgFWlaNNAO5hvbdNxu2hwyPJz08ZudT_fItc7w.9IFNovRqQyMlwDTdFWjp8ke1z3
sCUBIValrElV1J3bQrsqNCZWLeSFRM6Um5skzSgZar4B3Xe3W.Gjs3okivNbwENWIcBKYUfUF_ju
rNNsXUjs0ywAf9lYveqHCe.rZnIHpvJa83fwCEAcXSQF1JE5DNfyk1mq2BJuRlxYEiyQyfmKdjK9
flVOTBBVqqSzd5p.Fy0vswylFl6zRI5f.lQlDXxHE6QXHyRpbJ2tB.epTixtenmtd_HSm8VSOdUE
Rv4VuJ3JXI.GVOCktviba4NbEjdoXUqw7LtU37KA4D66gaNQrWtkwR4c4ZPCgo3mQrq8zUUJ39KB
7Sq9Mzg0z1KEs5SUQDn9n3rddfftyCNywHQ3.6jrOkfw0jwk5qHNmosuzx4M9sCcMBfjUg.2nCUZ
CKwWXoCTGrwhsAMJa6n6QiGCJTH_I2xCm6RH01J91ABbhePjyN0mwiO0G2KYDe.ksXGj7RA8QnVw
40oWeRroRfbJqglSSPyUSBeoF5oCXIIzDm4sU6l0RP0LlU02rQvOakw7zwb95e2V5PC1NRzyZqtx
OCSKbmT2gMOFu3_.2aI74H5P.Gp2Rg.OR2_U0fvASZbv28xZDG6sqgdHJBzVSEzI8Ox7Gl2Si
X-Sonic-MF: <avigross@verizon.net>
In-Reply-To: <iq0ctvF77tU1@mid.individual.net>
X-Mailer: Microsoft Outlook 16.0
Thread-Index: AQH8RFnQrsJfLkU50XE9+Q5aLLwBIgI1rsnrAZmhz74CSF0rE6sjx3aQ
Content-Language: en-us
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <026001d7a68b$e6865ff0$b3931fd0$@verizon.net>
X-Mailman-Original-References: <097bf31d-44e8-da35-df41-3834524716c9@DancesWithMice.info>
<she6e0$3bi$1@ciao.gmane.io>
<mailman.679.1631235193.4164.python-list@python.org>
<iq0ctvF77tU1@mid.individual.net>
 by: Avi Gross - Fri, 10 Sep 2021 21:36 UTC

In this discussion, I shudder to mention that people often simply use all kinds of additional logic to get a result. How much code have you seen that has some variable like "completed = False" that can be set to True in multiple places and many areas inside the loop are enclosed in an IF statement that only executes when completed remains False. So there is one clean exit in the sense that even when only half a loop has been done, it continues to the end of the loop and leaves before the next iteration. True, there is no break or return from the middle of the loop but logically there is if not for the convoluted code to avoid it.

Similarly, can most "while" loops that you want to be "until" loops not be made with a bit of code? I mean set first_time to True before starting. Set your while condition to while first_time OR condition or some other such logic. That guarantees you go into the loop even when condition is False. Within the loop, negate first_time.

Does that look more like a simulated repeat until, with extra overhead?

As I see it, there are many viewpoints here. From a programming perspective, it is nice to be able to state the overall shape of what you are doing in an upfront-way and also something others can read. Some things like the C-style for loop provide a bit of this but in a way I think outsiders may stare at as in for (initialize; compare-condition; iterate-change) { ... }

That is sort of compact but I have seen it get quite complex. If designed for readers, it might be designed a bit like what we do with keywords in functions headers where you might specify the "names" of each such section to make it clearer, and not just positional.

But some forms of loops like do {...} until ...

Make you have to scan forward to see what makes them end. That is not necessarily bad as you may need to read the code to see how it sets up the variables controlling the exit condition.

But if you want a wide open setup, where the conditions for the loop being entered can be specified, then the condition for it to be repeated (if different) can be specified and the condition at the end that makes you exit without trying the condition on top, you can go nuts. As mentioned, some languages have else clauses or finally clauses and error handling with things like try() or some kind of on.exit() can cause weird things. Some languages may even want you to be able to test some condition automatically after every single statement and exit immediately.

Even if you disagree with the idea of picking a few constructs that are commonly used or encouraged, you may want to consider what happens when you make a language so bloated that compiling or interpreting it becomes a big challenge and it has too many keywords.

When it comes to other perspectives like having algorithms able to evaluate a program and prove it has no bugs, you may end up with a very restricted programming language and still fail. Throw in the reality that your loop may use variable manipulated in parallel by other threads and that your thread may be killed as it runs and I wonder.

-----Original Message-----
From: Python-list <python-list-bounces+avigross=verizon.net@python.org> On Behalf Of Greg Ewing
Sent: Friday, September 10, 2021 2:40 AM
To: python-list@python.org
Subject: Re: Friday Finking: Contorted loops

On 10/09/21 11:47 am, Terry Reedy wrote:
> 2. It is rare useful. For loops are common. While loops are
> occasional (nearly an order of magnitude less common than for loops.
> Fractional loop constructs are rare.

I would say that fractional loops are more common than loops which truly need to execute completely at least once, and aren't bugs waiting to be triggered by an edge case such as empty input.

I seem to remember someone - maybe Wirth? - long ago expressing the opinion that repeat-until loops often tended to be error prone, but I can't provide a reference, sorry.

--
Greg

--
https://mail.python.org/mailman/listinfo/python-list

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor