Re: [Python-ideas] Spelling of Assignment Expressions PEP 572 (was post #4)
We have ways of cheating a bit if we want to reinterpret the semantics of something that nevertheless parses cleanly - while the parser is limited to single token lookahead, it's straightforward for the subsequent code generation stage to look a single level down in the parse tree and see that the code that parsed as "with expr" is actually "with subexpr as target".
It does work, however I think it does sound like a patch, and definitely it will block us to make other extensions in the future.
3) "target ? expr" (where ? is some other word/character - IIRC "target from expr" was proposed once)
A more popular convention is to mark `?` as handling boolean variables, so `target ? expr` could mean `expr if target else target`. Other proposal for null/boolean checking might need `?`, let's preserve `?` character for further development.
How about "name being expression" - this avoids the already used "as" while being searchable, reasonably short and gives a reasonably clear, (at least to English speakers), indication of what is going on. It can also be typed on an ASCII keyboard without having to have a helper program or memorising Unicode codes and can be displayed or printed without having to install specialised fonts.
It makes sense, if we don't have a long history in Python programming... A new keyword would be something very dangerous, because it just causes the crash of some existed library using the keyword as identifier.
On Mon, Apr 16, 2018 at 8:09 PM, Thautwarm Zhao
3) "target ? expr" (where ? is some other word/character - IIRC "target from expr" was proposed once)
A more popular convention is to mark `?` as handling boolean variables, so `target ? expr` could mean `expr if target else target`. Other proposal for null/boolean checking might need `?`, let's preserve `?` character for further development.
The only acceptable use of ? is formulated in PEP 505. -- --Guido van Rossum (python.org/~guido)
On Tue, Apr 17, 2018 at 6:09 AM, Thautwarm Zhao
3) "target ? expr" (where ? is some other word/character - IIRC "target from expr" was proposed once)
A more popular convention is to mark `?` as handling boolean variables, so `target ? expr` could mean `expr if target else target`. Other proposal for null/boolean checking might need `?`, let's preserve `?` character for further development.
Hey! I did not propose "?". Read the explanation in parenthesis. My whole idea that any option could be viable, as long as it does not propose reversed order notation. But anyway ":=" is better than any keyword imo. Mikhail
participants (3)
-
Guido van Rossum
-
Mikhail V
-
Thautwarm Zhao