A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/attachments/20171123/aef9bf99/attachment.html below:

<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 23 November 2017 at 18:11, Greg Ewing <span dir="ltr"><<a href="mailto:greg.ewing@canterbury.ac.nz" target="_blank">greg.ewing@canterbury.ac.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">Ivan Levkivskyi wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
"People sometimes want to refactor for-loops containing `yield` into a comprehension but that doesn't work (particularly because of the hidden function scope) - lets make it a SyntaxError"<br>
</blockquote>
<br></span>
Personally I'd be fine with removing the implicit function<br>
scope from comprehensions and allowing yield in them, since<br>
the semantics of that are clear.<br></blockquote><div><br></div><div>People keep saying this, but seriously, those semantics aren't clear at all once you actually start trying to implement it.</div><div><br></div><div>Yes, they're obvious in simple cases, but it isn't the simple cases that are the problem.</div><div><br></div><div>Instead, things start getting hard once you're dealing with:</div><div><br></div>- unpacking to multiple variable names<div><div><div>- nested loops in the comprehension<br></div><div>- lexical closures inside the comprehension (e.g. lambda expressions, comprehensions inside comprehensions)</div><div><br></div></div><div>Hence the approach we ended up going with for <a href="https://bugs.python.org/issue1660500">https://bugs.python.org/issue1660500</a>, which was to use a real function scope that already handled all of those potential problems in a well defined way.</div><div><br></div></div><div>Technically we *could* define new answers to all of those situations, but then we're stuck explaining to everyone what those new behaviours actually are, and I think that will actually be harder than the status quo, where we only have to explain why these implicit scopes act much the same way that "lambda: await expr" and "lambda: yield expr" do.</div><div></div><br><div>Cheers,</div><div>Nick.<br></div><br></div>-- <br><div class="gmail_signature">Nick Coghlan   |   <a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>   |   Brisbane, Australia</div>
</div></div>

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4