Language Design: Unified Condition Syntax


Published on 2019-09-21.

How to Parse?


Further Considerations

A reasonable question that might be asked is whether this design can be extended to also handle thrown exceptions, and whether such an extension could completely replace the try-catch-finally idiom.

One language that has done something similar is Ocaml, which has extended its pattern matching syntax/semantics.

One option might be something along the lines of

if readPersonFromFile(file)
  throws[IOException]($ex)        then "unknown, due to $ex"
  is Person("Alice", _)           then "alice"
  is Person(_, $age) && age >= 18 then "adult"
                                  else "minor"