[Python-ideas] PEP 315: do-while

jimjhb at aol.com jimjhb at aol.com
Fri Jun 28 16:22:39 CEST 2013



Stephen Turnbull writes:


 >Shane Green writes:

 >> List comprehensions are concise, intuitive, and efficient; proper
 >> use can improve readability *and* performance significantly.

>Truth, the whole truth, and nothing but the truth.

 >> The number of proper applications is limited by list comprehension
 >> limitations.

>Truth, but not the whole truth.

 >> Adding the ability to configure termination in the comprehension
 >> will increase that number.

>Not necessarily.  In fact, any programming construct is limited by
>*human* comprehension limitations.  As has been pointed out by people
>who think about these issues deeply and push these constructs to their
>limits, *because* a comprehension[1] is an *expression*, nested
>comprehensions (nested in higher-level expressions) are possible.
>Adding clauses to the construct increases the complexity, and
>comprehensions are already pretty complex.[2]

>Personally, *because* iterables can be infinite, I think the lack of a
>stop clause in comprehensions is ugly and adds some unobvious
>complexity to comprehensions and displays.  The programmer needs to
>also keep in mind the possibility that some iterables are infinite,
>and deal with that.  The convenience value of an internal
>"takewhile()" is also undeniable.  I'd like to see the feature added.

>But I definitely see this as a tradeoff, and I don't know how costly
>the increased complexity of comprehensions would be to folks who push
>the limits of comprehension usage already.  Increased complexity in
>the basic construct might push them over the limit, and they would
>*decrease* usage.[3]  Nick et al clearly are concerned about that end
>of the spectrum, and I personally would place those needs over mine in
>this case.  (YMMV, that's just my opinion about *me*.)


>Footnotes:
<deleted>
The takewhile syntax is kind of god awful.  The lambda thing always gives
me pause, though I now 'grok' the whole thing to be a conditional.
I don't think the issue is about added complexity to the comprehension
(as the added clause would be optional anyway) but the twists and turns
needed internally to get it working, and the open question about whether
the syntactical implications can be adequately 'contained'.  


 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130628/cf832a01/attachment.html>


More information about the Python-ideas mailing list