• esa@discuss.tchncs.deOP
    link
    fedilink
    arrow-up
    1
    ·
    3 months ago

    Parsing is a way of “validating early”. You either get a successful parse and the program continues working on known-good data with that knowledge encoded in the type system, or you handle incorrect data as soon as it’s encountered.

      • zygo_histo_morpheus@programming.dev
        link
        fedilink
        arrow-up
        0
        ·
        3 months ago

        Why do you think it’s a bad idea? Both you and OP are in agreement that you should validate early, which seemed to be what your first comment was about. Is it encoding that the data has been validated in the typesystem that you disagree with?

        • thenextguy@lemmy.world
          link
          fedilink
          arrow-up
          1
          ·
          3 months ago

          I disagree that parsing is validating. For example, you could give me a valid ISO date time string, but I want a shipping date and you gave me something in the past. It parses, but is not valid.

          I disagree that validating early is bad because some other part of the code might also validate later and possibly do it differently. Yes, that’s bad, but not a reason to not validate early.