Open developedby opened 3 months ago
I'd like to propose two seemingly unconsidered alternatives, each of which would fix the expression-statement issue:
condition ? is_true : is_false
Functional syntax: (? condition is_true is_false)
ifelse
function.
Imperative syntax: ifelse(condition, is_true, is_false)
Functional syntax: (ifelse condition is_true is_false)
The C-like option would be less Python-like, but would still be familiar to most developers and would be more concise. On the other hand, the ifelse
option would be more Python-like, but would run the risk of potentially breaking programs that have an ifelse
in their namespace.
At the moment, all pattern matching syntax happens only at the statement level. This makes writing some stuff a pain.
For example, if we want to write a
max
function with a lambda, that's not possible.I propose the addition of python-like
if
expressions:lambda a, b: a if a > b else b
This is ok, but opens the can of worms of what statements should have expression versions, which i'd like to be 0.
Alternatives: