[Python-ideas] Modern language design survey for "assign and compare" statements

Chris Angelico rosuav at gmail.com
Sat May 19 22:18:18 EDT 2018


On Sun, May 20, 2018 at 11:43 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> Out of those industry standard languages (as ranked by TIOBE, other
> methodology may result in other rankings) we find:
>
> 8/12 have some form of assignment expressions;
> (Java, C, C++, C#, PHP, Javascript, Ruby, R)
>
> 4/12 do not (Python, VB .Net, SQL, Delphi).
>

SQL isn't really comparable here. To figure out whether Python is in
better company *with* or *without* assignment expressions, we need to
compare with languages that have a concept of "assignment" and
"expression". SQL itself most certainly has expressions, but it
doesn't have assignment per se. There are named sub-expressions in
SELECT statements, but that's more of a temporary view on a table than
anything like a Python variable / name binding; I don't think standard
SQL has any way to fetch up a scalar value and then reuse it, other
than burying it in a table and selecting twice from that table. Some
database engines have an SQL-based procedural language, but it's
non-standard. FWIW, PostgreSQL's "PL/pgSQL" has assignment, but it is
a statement and not an expression, probably because its expression
evaluator is defined in terms of SQL's SELECT statement.

So there are really eleven: eight that do, two that don't, and one
that currently doesn't, but its BDFL is discussing the possibility of
adding it.

ChrisA


More information about the Python-ideas mailing list