• SorteKanin@feddit.dkOP
    link
    fedilink
    arrow-up
    12
    ·
    16 days ago

    So basically their argument is that the missing piece is anonymous sum types. I tend to agree! It would be amazing to have that as a language feature, i.e. Result<(), FooError | BarError>. Unfortunately that is unlikely to arrive to the language for a loooong time… But I think I will definitely try out this library in the meantime.

    • BB_C@programming.dev
      link
      fedilink
      arrow-up
      3
      ·
      16 days ago

      A language feature is not needed because macros exist.

      I would even argue that perhaps the most important role macros play is blocking adding endless language features 😉

      • SorteKanin@feddit.dkOP
        link
        fedilink
        arrow-up
        2
        ·
        16 days ago

        Macros are often not very ergonomical to use compared to language features.

        Also, why anonymous product types but not anonymous sum types? It seems kind of weird to me. Anonymous sum types can be just as useful as anonymous product types, as the blog post illustrates quite well I think.

        • BB_C@programming.dev
          link
          fedilink
          arrow-up
          2
          ·
          15 days ago

          The language wouldn’t have lost much without tuples actually. But they do at least have direct pattern destructuring utility. Anonymous enums don’t.

          They also don’t pose potential future awkwardness if/when variant types become a thing.

  • Ephera@lemmy.ml
    link
    fedilink
    arrow-up
    3
    ·
    16 days ago

    Damn, this looks like it might solve my pain points with error handling. Will have to see, if it replaces them with new pain points, since error handling is fundamentally hard, but at least, it isn’t starting completely from scratch…