Comment by dinosaurdynasty

5 years ago

Rust seems pretty close to this (with Result<T, E>), though there is also the panic system.

it's trivial in any language to define and use a Result<T, E> type.

  • No, not really. Languages that don’t really embrace such a type can usually never make its use ergonomic. Adding such a construct to C or Java would be “trivial” but its use would be exceedingly painful.

  • That depends a lot on what you mean by "use". Pretty much every commonly used language would be able to define something that can hold one of two things and provide ways to determine which one is present and retrieve one of the two options, but comparatively few are going to be able to provide the same guards against accidental or intentional misuse that pattern matching gets you.