<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 2 March 2018 at 16:39, Ethan Furman <span dir="ltr"><<a href="mailto:ethan@stoneleaf.us" target="_blank">ethan@stoneleaf.us</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 03/01/2018 09:08 PM, Nick Coghlan wrote:</span><br><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Adding statement local variables into that mix *without* some form of syntactic marker would mean taking an already<br>
complicated system, and making it even harder to reason about correctly (especially if statement locals interact with<br>
nested scopes differently from the way other locals in the same scope do).<br>
</blockquote>
<br></div></div>
Seems like it would far easier and (IMHO) more useful to scale the proposal back from a statement scope to simple expression assignment, and the variable is whatever scope it would have been if assigned to outside the expression (default being local, but non-local or global if already declared as such).<br></blockquote><div><br></div><div>Because that would put us back in the exact same problematic situation we had when "[x*x for x in sequence]" leaked the iteration variable (only worse): no function locals would be safe, since arbitrary expressions could clobber them, not just name binding operations (assignment, import statements, for loops, with statements, exception handlers, class and function definitions).<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
No grammatical grit on anyone's monitor, no confusion about which variable is being accessed, and no confusion about the lifetime of that variable (okay, no /extra/ confusion ;) .<br></blockquote><div><br></div><div>Unfortunately, it would mean a lot more "All I did was name a repeated subexpression and now my function is behaving weirdly".<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Maybe somebody could explain why a statement-local limited scope variable is better than an ordinary well-understood local-scope variable? Particularly why it's better enough to justify more line-noise in the syntax. I'm willing to be convinced (not happy to, just willing ;) .<br></blockquote><div><br></div><div>It breaks the expectation that only a well defined subset of statement can make changes to local name bindings.<br></div></div><br></div><div class="gmail_extra">Cheers,<br></div><div class="gmail_extra">Nick.<br clear="all"></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Nick Coghlan | <a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a> | Brisbane, Australia</div>
</div></div>