HigherOrderCO / Bend

A massively parallel, high-level programming language
https://higherorderco.com
Apache License 2.0
17.1k stars 420 forks source link

(Request) If expressions #419

Open developedby opened 3 months ago

developedby commented 3 months ago

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:

qwergle commented 2 months ago

I'd like to propose two seemingly unconsidered alternatives, each of which would fix the expression-statement issue:

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.