• lad
    link
    fedilink
    English
    arrow-up
    4
    ·
    2 months ago

    you never know what code your function or library calls that can produce an exception

    As far as I remember, there were several attempts at introducing exceptions into type system, and all have failed to a various degree. C++ abandoned the idea completely, Java has a half-assed exception signature where you can always throw an unexpected exception if it’s runtime exception, mist likely there were other cases, too.

    So yeah, exception as part of explicit function signature is a vast improvement, I completely agree

    • thingsiplay@beehaw.org
      link
      fedilink
      arrow-up
      1
      ·
      2 months ago

      So yeah, exception as part of explicit function signature is a vast improvement, I completely agree

      Hmm, I’m not sure if you are being sarcastic. In my reply I didn’t meant encoding Exceptions into Type system. Is this a type and you probably meant “Error Types as part of” instead “exception as part of”?

      Honestly I don’t know how Exceptions as part of type system would even look like. Because each function call in a chain would need to have all information from previous function call, otherwise that information gets lost to the next caller. The problem is the hierarchy of function and method calls. Somewhere some objects and functions can be edited to Throw a new Exception, that is not handled through the entire chain. And for the higher function caller, there is 0% way of knowing that (through code, besides documentation off course).

      • lad
        link
        fedilink
        English
        arrow-up
        3
        ·
        2 months ago

        Yeah, I shaped my words poorly. What I meant is that errors are sort of equivalent to exceptions, but errors are first class citizens of type system, and this is an improvement over exceptions being kind of independent of type

        • thingsiplay@beehaw.org
          link
          fedilink
          arrow-up
          2
          ·
          2 months ago

          Ah it was intentional and now I see how it was meant. It makes perfectly sense, it was just not clear before. :-) Human language and interpreter is not as precise like programming language.^^