<div dir="ltr"><div class="gmail_default" style="font-size:small"><span style="font-size:13px">On Sun, 29 Apr 2018 at 10:30, Tim Peters <<a href="mailto:tim.peters@gmail.com">tim.peters@gmail.com</a>> wrote:</span><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">[Tim Delaney <<a href="mailto:timothy.c.delaney@gmail.com" target="_blank">timothy.c.delaney@gmail.com</a>>]<br>
> My big concern here involves the:<br>
><br>
<div class="gmail_default" style="font-size:small;display:inline">​​</div>> if local(m = re.match(regexp, line)):<br>
>     print(m.group(0))<br>
><br>
> example. The entire block needs to be implicitly local for that to work -<br>
> what happens if I assign a new name in that block?<br>
<br>
I really don't know what you're asking there.  Can you make it<br>
concrete?  If, e.g., you're asking what happens if this appeared after<br>
the `print`:<br>
<br>
        x = 3.14<br>
<br>
then the answer is "the same as what would happen if `local` had not<br>
been used".  We can't know what that is without context, though.<br>
Maybe x is global.  Maybe x was declared nonlocal earlier.  Maybe it's<br>
function-local.  While it may be irrelevant to what you're asking, I<br>
noted just before:<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">That's exactly what I was asking, and as I understand what you're saying, we would have a local name m available in the indented block which went away when the block ended, but any names modified in the block are not local to the block. That seems likely to be a source of errors.</div></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">To clarify my understanding, if the names 'x' and 'm' did not exist prior to the following code, what would x and m refer to after the block completed?</div><div class="gmail_default" style="font-size:small"><br></div><div><span style="color:rgb(34,34,34);font-family:sans-serif;font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><div class="gmail_default" style="font-size:small;display:inline">​​</div>if local(m = re.match(regexp, line)):</span></div><div><div class="gmail_default" style="font-size:small">​    x = 1</div><div class="gmail_default" style="font-size:small">    m = ​2</div></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
>> if local(m = re.match(regexp, line)):<br>
>>     print(m.group(0))<br>
<br>
> if local { m = re.match(regexp, line) }:<br>
>     print(m.group(0))<br>
<br>
OK, this is the only case in which you used it in an `if` or `while`<br>
expression.  All the questions you asked of me at the start can be<br>
asked of this spelling too. <div class="gmail_default" style="font-size:small;display:inline">​ ​</div>You seemed to imply at the start that the<br>
right curly brace would always mark the end of the new scope.  But if<br>
that's so, the `m` in `m.group()` has nothing to do with the `m`<br>
assigned to in the `local` block - _that_ scope ended before `print`<br>
was reached.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">​Yes - I think this is exactly the same issue as with your proposed syntax.​</div></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
So if you're not just trying to increase the level of complexity of<br>
what can appear in a local block, a fundamental problem still needs<br>
solving ;-)  I suppose you could solve it like so:<br>
<br>
local { m = re.match(regexp, line)<br>
           if m:<br>
               print(m.group(0))<br>
         }<br>
<br>
but, besides losing the "shortcut", it would also mean something<br>
radically different if<br>
<br>
               x = 3.14<br>
<br>
appeared after the "print".  Right?  If a "local block" is taken<br>
seriously, then _all_ names bound inside it vanish when the block<br>
ends.</blockquote><div><br></div><div class="gmail_default" style="font-size:small">​Indeed, and I don't have a proposal - just concerns it wold be very difficult to explain and understand exactly what would happen in the case of something like:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">

<div style="color:rgb(34,34,34);font-family:sans-serif;font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><span style="color:rgb(34,34,34);font-family:sans-serif;font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><div class="gmail_default" style="font-size:small;display:inline">​</div>if local(m = re.match(regexp, line)):</span></div><div style="color:rgb(34,34,34);font-family:sans-serif;font-size:13px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><div class="gmail_default" style="font-size:small">​    x = 1</div><div class="gmail_default" style="font-size:small">    m = ​2</div></div>

<br></div><div class="gmail_default" style="font-size:small">Regarding the syntax, I didn't want to really change your proposal, but just thought the functionality was different enough from the function call it appears to be that it probably merits different syntax.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Tim Delaney</div></div></div>