• @tzrlk@lemmy.world
    link
    fedilink
    English
    21 month ago

    That sounds a lot like how checked exceptions work, though with some terser handling syntax.

    • @Zykino@programming.dev
      link
      fedilink
      English
      21 month ago

      First time I hear about checked exceptions. How do you use them ? Are you forced to handle them explicitly ? Is the handling checked at compile time ?

      • @kablammy@sh.itjust.works
        link
        fedilink
        English
        21 month ago

        Checked exceptions require a function to declare the exceptions it can throw. The caller function must then catch and handle the exception, or the exception would bubble up a level, in which case the caller must also include that exception among the exceptions it declares that it can throw. I don’t know if C++ does this, but Java/C# do. It sounds exactly like Rust’s system except with different syntax.