<div dir="ltr"><div>Please, Mike, can you stop? The race is over and your horse has lost. I really value all the input I've received during the months of discussion (including your research into what other languages do), but in the end my "evaluation function" (to use somewhat hip lingo :-) is different from yours. For a while I seriously considered "EXPR as NAME", but when comparing examples written in one style vs. another I just liked "NAME := EXPR" better every time. In addition to the problems with "with" (which everyone has read about already) and the general rule that "as" is preceded by specific syntax that predicts it (i.e. "import", "except" or "with"), I found that when skimming the code it was easier to miss the definition of NAME with the "as" form than with the ":=" variant.</div><div><br></div><div>There was also someone who posted that they believe that the problems with evaluation order (alluded to in the PEP) would be solved by the "as" form. However that's not the case -- in fact I believe that Python would have to generate exactly the same bytecode for "EXPR as NAME" as for " NAME := EXPR", since in both cases it comes down to "LOAD EXPR; STORE NAME" (in pseudo bytecode). So neither form supports things like "x == (x := f())" since this comes down to</div><div><br></div><div>LOAD x</div><div>LOAD f</div><div>CALL</div><div>STORE x</div><div>COMPARE</div><div><br></div><div>with either syntax variant (again, in pseudo bytecode).<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Jul 4, 2018 at 5:09 PM Mike Miller <<a href="mailto:python-dev@mgmiller.net">python-dev@mgmiller.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Recently on Python-Dev:<br>
<br>
On 2018-07-03 15:24, Chris Barker wrote:<br>
 > On Tue, Jul 3, 2018 at 2:51 PM, Chris Angelico <<a href="mailto:rosuav@gmail.com" target="_blank">rosuav@gmail.com</a><br>
 >     On Wed, Jul 4, 2018 at 7:37 AM, Serhiy Storchaka <<a href="mailto:storchaka@gmail.com" target="_blank">storchaka@gmail.com</a>><br>
 ><br>
 >     > I believe most Python users are not<br>
 >     > professional programmers -- they are sysadmins, scientists, hobbyists<br>
 >     > and kids --<br>
 ><br>
 >     [citation needed]<br>
 ><br>
 > fair enough, but I think we all agree that *many*, if not most, Python users<br>
 > are "not professional programmers". While on the other hand everyone involved<br>
 > in discussion on python-dev and python-ideas is a serious (If not<br>
 > "professional") programmer.<br>
<br>
<br>
Python Audience - wants clarity:<br>
<br>
Not sure I'd say that most users are not professionals, but one major strength <br>
of Python is its suitability as a teaching language, which enlarges the <br>
community every year.<br>
<br>
Additionally, I have noticed a dichotomy between prolific "C programmers" who've <br>
supported this PEP and many Python programmers who don't want it.  While C-devs <br>
use this construct all the time, their stereotypical Python counterpart is often <br>
looking for simplicity and clarity instead.  That's why we're here, folks.<br>
<br>
<br>
Value - good:<br>
<br>
Several use cases are handled well by PEP 572.  However it has been noted that <br>
complexity must be capped voluntarily relatively early—or the cure soon becomes <br>
worse than the disease.<br>
<br>
<br>
Frequency - not much:<br>
<br>
The use cases for assignment-expressions are not exceedingly common, coming up <br>
here and there.  Their omission has been a very mild burden and we've done <br>
without for a quarter century.<br>
<br>
Believe the authors agreed that it won't be used too often and won't typically <br>
be mis- or overused.<br>
<br>
<br>
New Syntax - a high burden:<br>
<br>
For years I've read on these lists that syntax changes must clear a high <br>
threshold of the (Value*Frequency)/Burden (or VF/B) ratio.<br>
<br>
Likewise, a few folks have compared PEP 572 to 498 (f-strings) which some former <br>
detractors have come to appreciate.  Don't believe this comparison applies well, <br>
since string interpolation is useful a hundred times a day, more concise, clear, <br>
and runs faster than previous functionality.  Threshold was easily cleared there.<br>
<br>
<br>
Conclusion:<br>
<br>
An incongruous/partially redundant new syntax to perform existing functionality <br>
more concisely feels too low on the VF/B ratio IMHO.  Value is good though <br>
mixed, frequency is low, and burden is higher than we'd like, resulting in "meh" <br>
and binary reactions.<br>
<br>
Indeed many modern languages omit this feature specifically in an effort to <br>
reduce complexity, ironically citing the success of Python in support.  Less is <br>
more.<br>
<br>
<br>
Compromise:<br>
<br>
Fortunately there is a compromise design that is chosen often these days in new <br>
languages---restricting these assignments to if/while (potentially comp/gen) <br>
statements.  We can also reuse the existing "EXPR as NAME" syntax that already <br>
exists and is widely enjoyed.<br>
<br>
This compromise design:<br>
<br>
     1  Handles the most common cases (of a group of infrequent cases)<br>
     0  Doesn't handle more obscure cases.<br>
     1  No new syntax (through reuse)<br>
     1  Looks Pythonic as hell<br>
     1  Difficult to misuse, complexity capped<br>
<br>
     Score: 4/5<br>
<br>
PEP 572:<br>
<br>
     1  Handles the most common cases (of a group of infrequent cases)<br>
     1  Handles even more obscure cases.<br>
     0  New syntax<br>
     0  Denser look: more colons, parens, expression last<br>
     0  Some potential for misuse, complexity uncapped<br>
<br>
     Score: 2/5<br>
<br>
<br>
Thanks for reading, happy independence,<br>
-Mike<br>
<br>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/guido%40python.org" rel="noreferrer" target="_blank">https://mail.python.org/mailman/options/python-dev/guido%40python.org</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido">python.org/~guido</a>)</div>