On Wed, Nov 29, 2017 at 3:12 PM Serhiy Storchaka <storchaka@gmail.com> wrote:
29.11.17 15:01, Stephan Houben пише:
> What about a more general:
>
> A if <binary_relation> B else C
>
> which would allow
>
> A if is not None else C
>
> but also e.g.
>
> A if >= 1 else 0

This look the most "natural" to me. I.e. the least "unnatural". If we
even will introduce a new special syntax I will prefer this syntax.

The only disadvantage is that this will prevent introducing "angular
parenthesis" in future: A if <X, Y, Z> == B else C.


Also, how do you treat more complex conditions? do you prohibit them?

    A if >= 0 and < 2 else 0
    B if >= 0 or < -1 else -1
    C if and B else A   # i.e. C if C and B else E
    D if -y else E  # is this an unary minus or a binary operation?

If any of these is allowed, it might confuse people.
It also break the ability to extract subexpression to variables.

(I kinda like this idea, but it doesn't look like a small, simple change to the language, whereas ?? does).

Elazar