[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] PEP 572: Do we really need a ":" in ":="?

[Alexander Belopolsky]

> > Do we want to protect users who
> > cannot tell = from == so much that  we are willing to cause Python to be
> > the first language with two non-interchangeable assignment operators?

[Steven D'Aprano][

Not even close to the first. Go beat us to it -- it has both = and :=
> assignment operators.
> Ocaml also has := for regular assignment and <- for assignment to
> mutable fields.
> Similarly, Haskall has = for assignment definitions and <- for binding
> in monads.

I skipped that part, because nobody actually cares ;-)

But back when I looked at this, R had them all beat, and I never found a
single source that actually managed to list _all_ of R's variations  This
source was clearest, but is missing (at least) all the ways to spell all
the variations as function calls too:


There are three different assignment operators: two of them have leftwards
> and rightwards forms.

The operators <- and = assign into the environment in which they are
> evaluated. The operator <- can be used anywhere, whereas the operator = is
> only allowed at the top level (e.g., in the complete expression typed at
> the command prompt) or as one of the subexpressions in a braced list of
> expressions.

The operators <<- and ->> are normally only used in functions, and cause a
> ...
> .[click the link if you're still awake]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180705/ee3e7202/attachment.html>