A design that subsumes the various syntactic forms of
ifstatements/expressionsswitchon valuesmatchon patterns and pattern guardsif-letconstructs
and scales from simple one-liners to complex pattern matches.
https://soc.me/languages/unified-condition-expressions
A design that subsumes the various syntactic forms of
if statements/expressionsswitch on valuesmatch on patterns and pattern guardsif-let constructsand scales from simple one-liners to complex pattern matches.
7 Comments
mobotsar@sh.itjust.works · 3 pts · 1y
A quite decent syntax and an excellent domain name!
tyler@programming.dev · 2 pts · 1y
How does $person get set?
soc@programming.dev · 2 pts · 1y
Good catch, that should have been
if personin the first line.It's been a left-over from when syntax looked like this:
considerealization@lemmy.ca · 2 pts · 1y
Isn't
matchalready such a unified expression? Especially once you extend matches with guards, it seems to me like this is a solved problem. E.g.,is
and
is (and IMO reads much clearer this way):
and
is
and
is
.
Finally,
Would be the simple
Seems to me this reads more clear in general and has less magic. Plus, it's already implemented in a bunch of languages.
soc@programming.dev · 1 pts · 1y
Sure, there are some worse/more limited predecessors – my design was partially motivated by a desire to improve upon these.
For instance, that ML-derivative you are using for your examples
if then elsein the language, thus making it not unifiedmatchis very limited in which coding patterns it can expressAlso, none of the examples are "more clear" or "have less magic":
Maybe they are more "familiar" to you personally, but that's about it.
Too me they just look clunky, full of accidental complexity and trying to work around a poor/limited language design.
armchair_progamer@programming.dev · 1 pts · 1y
This looks very similar to The Ultimate Conditional Syntax, although that's for ML so it doesn't have the nice syntax for chaining method calls.
soc@programming.dev · 1 pts · 1y
The author of that paper hung around in the lang design forum were I originally presented this.