A design that subsumes the various syntactic forms of

  • if statements/expressions
  • switch on values
  • match on patterns and pattern guards
  • if-let constructs

and scales from simple one-liners to complex pattern matches.

  • soc@programming.devOP
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    3 months ago

    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

    • very likely still has if then else in the language, thus making it not unified
    • desperately tries to emulate functionality with guards that simply comes out of the box with my approach
    • relies on the ultimate hack of “match on unit”, because match is very limited in which coding patterns it can express

    Also, 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.