On 2021-01-15T12:02:41 -0500 Brian Goetz <brian.go...@oracle.com> wrote:
> Maurizio had a clever idea for how to rescue this issue. > > As in (not a serious syntax proposal): > > try-match (x : big-honking-pattern) { > // happy-path code > } > catch (MatchFailException e) { // checked exception > // exception captures which sub-pattern failed > } > Hah, synchronicity! Yes, I was drafting an email with a suggestion for something similar, although i used a __MATCH_OR_DIE expression form that looked like a cast, and an unchecked exception. Did I just imagine it, or was there a suggestion for something like this in the past?: var Point(var x, var y) = ... That would have a similar aspect of assertion (as it does in Haskell, ML, etc) and would obviously need to have the same "match or die" semantics. I think something akin to try-match is perfectly reasonable. -- Mark Raynsford | https://www.io7m.com