[Python-Dev] assignment expressions: an alternative alternative proposal

Guido van Rossum guido at python.org
Tue Apr 24 18:54:30 EDT 2018


We should really take this back to python-ideas at this point.

On Tue, Apr 24, 2018 at 3:16 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:

> On Tue, 24 Apr 2018 09:38:33 -0400
> Yury Selivanov <yselivanov.ml at gmail.com> wrote:
> > I propose to use the following syntax for assignment expressions:
> >
> >     ( NAME = expr )
> >
> > I know that it was proposed before and this idea was rejected, because
> > accidentally using '=' in place of '==' is a pain point in
> > C/C++/JavaScript.
>
> To solve this issue, I would suggest another syntax:
>
>     var NAME = expr
>
> Strong points:
> - the "var" keyword makes it clear that it's not a mistyped equality
>   ("var NAME == expr" would be a syntax error)
> - the "var" keyword can stand out thanks to syntax highlighting
> - the "=" which traditionally spells assignement is there as well
>
> Weak points:
> - we need a deprecation cycle before "var" can be used as a keyword
>
> (alternative keyword choices against "var": "using", "let", "bind"...)
>
> Regards
>
> Antoine.
>
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/
> guido%40python.org
>



-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180424/f992b509/attachment.html>


More information about the Python-Dev mailing list