[Python-ideas] Inline assignments using "given" clauses

Kirill Balunov kirillbalunov at gmail.com
Thu May 10 16:44:25 EDT 2018


2018-05-10 16:44 GMT+03:00 Guido van Rossum <guido at python.org>:

> I'm sorry, but unless there's a sudden landslide of support for 'given' in
> favor of ':=', I'm really not going to consider it.
>
> I'd pronounce "if (x := y) > 0" as either "if y (assigned to x) is greater
> than zero" or "if x (assigned from y) is greater than zero".
>


I think you do not quite objectively look at the current situation. Many
just lost interest in attempts to move the topic at least a little bit in
the other way, seeing how you and Tim so actively expresses
support/protects this `:=` syntax, while ignoring or pushing out
alternative opinions :-). Of course, the latter is partly due to the
incredible number of different threads and messages on this topic.

Briefly:

Initially, the main argument in favor of `:=` was that this form is similar
to the usual assignment statement, but can be used as an expression. Ok.

Then everyone agreed with the idea that it's necessary to limit assignment
target to name only. Although all this criticism was actually put forward
in the first 50-100 messages on the topic.

In the same first hundred it was actively discussed, that in fact, this
idea gives a win only in `while` and `if` statemetns that probably will
match 99%+ where it will be used for its intended purpose. At the same
time, most of the criticism concerned exactly the use in generators and
comprehenshions, they are already often overloaded for perception. And as
you once said - "Language Design Is Not Just Solving Puzzles".

There was also discussed the difference in perception between the `expr op
name` and `name op expr`. Here the expression is something that is
important, the name is only a convenient consequence.

At the moment with all the constraints of `:=`, the discuscation is more
like - trying to cram this syntax into the language. While for those who
are familiar with Pascal, Icon and other languages that use this syntax,
this - `:=` looks natural. For others and I believe such a majority among
users, this syntax is, to put it mildly, not natural and ugly producing a
line noise, the colon `:` symbol is already used in a lot of places.

With all the changes, the limitations and magic with scopes. Is it now
easier to explain all the differences between `=` and `:=`, than the
difference between `if expr as name ...: ...` and `with expr as name:`?

Therefore, I take Nick's insistent position as an attempt to at least
somehow make an alternative look at this topic.


With kind regards,
-gdg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180510/7d1d3861/attachment-0001.html>


More information about the Python-ideas mailing list