On Fri, Apr 13, 2018 at 10:22 PM, Steven D'Aprano <st...@pearwood.info> wrote:
> On Wed, Apr 11, 2018 at 11:50:44PM +1000, Chris Angelico wrote:
>> > Previously, there was an alternative _operator form_  `->`  proposed by
>> > Steven D'Aprano. This option is no longer considered? I see several
>> > advantages with this variant:
>> > 1. It does not use `:` symbol which is very visually overloaded in Python.
>> > 2. It is clearly distinguishable from the usual assignment statement and
>> > it's `+=` friends
>> > There are others but they are minor.
>> I'm not sure why you posted this in response to the open question, but
>> whatever. The arrow operator is already a token in Python (due to its
>> use in 'def' statements) and should not conflict with anything;
>> however, apart from "it looks different", it doesn't have much to
>> speak for it.
> On the contrary, it puts the expression first, where it belongs
> *semi-wink*.

The 'as' syntax already has that going for it. What's the advantage of
the arrow over the two front-runners, ':=' and 'as'?

> The expression is the most important part of the assignment expression,
> and because we read from left to right, it should come first. Let's take
> a simple example:
>     pair = (first_value := x + y + z,
>             a + b + first_value
>             )
> What's the first item of the pair? If you're like me, and I think most
> people are similar, when skimming the code, you read only far across
> each line to get an idea of whether it is relevant or not.

Yet Python has an if/else operator that, in contrast to C-inspired
languages, violates that rule. So it's not a showstopper. :)

>> The arrow faces the other way in languages like Haskell,
> Indeed, but in R, it faces to the right. (Actually, R allows both
> direction.) There's also apparently a language BETA which uses -> for
> assignment, although I've never used it.

I looked up R's Wikipedia page and saw only the left-facing arrow. How
common is the right-facing arrow? Will people automatically associate
it with name binding?

> HP calculator "RPN" language also includes a -> assignment operator for
> binding named parameters (taken off the stack) inside functions, except
> they use a custom encoding with an arrow symbol, not a literal
> hyphen+greater-than sign.
> Likewise for TI Nspire calculators, which also use an right-pointing
> arrow assignment operator. (They also have a Pascal-style := operator,
> so you're covered both ways.) This comes from various dialects of
> calculator BASIC.

So we have calculators, and possibly R, and sorta-kinda Haskell,
recommending some form of arrow. We have Pascal and its derivatives
recommending colon-equals. And we have other usage in Python, with
varying semantics, recommending 'as'. I guess that's enough to put the
arrow in as another rejected alternate spelling, but not to seriously
consider it.

Python-ideas mailing list
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to