Python is DOOMED! Again!

Ian Kelly ian.g.kelly at gmail.com
Sun Feb 8 03:31:48 EST 2015


On Sat, Feb 7, 2015 at 5:45 PM, Albert van der Horst
<albert at spenarnc.xs4all.nl> wrote:
> It is too bad `` -> ''  as a token is now taken.
> I wanted to propose to replace the ternary syntax
> lambda  ..  : ..
> by a regular operator
> .. -> ..
> then we could have
> x -> x**2
> instead of
> lambda x : x**2

Well, I don't think the existing syntax is incompatible with your
proposal. As it is, the -> token can only appear after the argument
list of a def statement, so there would be no grammatical ambiguity. I
do think that such a proposal is unlikely to gain wide support though.

> Moreover the value of a function would be a lambda
>
> not
> def square(x): x**2
> but
> square = x->x**2

This would be an anti-pattern. The def statement associates the name
"square" with the function's __name__ attribute, which is useful for
debugging and introspection. The proposed assignment statement does
not.

> mult  = x,y ->
>    result = 0
>    for i in range(x):
>       result +=y
>    return result

I don't like this at all. I read "x -> x**2" as denoting a mapping
from a bound variable to an expression. A whole function body just
feels wrong here.

> doing away with the ternary operator def

def is a statement, not an operator.

> replacing it by two binary operators, one of them (=) being thoroughly familiar.

= is also not an operator.

> Also name:str is the wrong order.

I disagree; "name: type" is linguistically correct, with the colon
denoting that what comes after describes what comes before. Without
the colon, the opposite order would make more sense.



More information about the Python-list mailing list