• BB_C@programming.dev
    link
    fedilink
    arrow-up
    1
    arrow-down
    1
    ·
    5 months ago

    From my experience, when people say “don’t unwrap in production code” they really mean “don’t call panic! in production code.” And that’s a bad take.

    What should be a non-absolutest mantra can be bad if applied absolutely. Yes.

    Annotating unreachable branches with a panic is the right thing to do; mucking up your interfaces to propagate errors that can’t actually happen is the wrong thing to do.

    What should be a non-absolutest mantra can be bad if applied absolutely.

    • cbarrick@lemmy.world
      link
      fedilink
      English
      arrow-up
      1
      ·
      5 months ago

      You talk about “non-absolutist,” but this thread got started because the parent comment said “literally never.”

      I am literally making the point that the absolutist take is bad, and that there are good reasons to call unwrap in prod code.

      smdh

      • BB_C@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        5 months ago

        Don’t get angry with me my friend. We are more in agreement than not re panics (not .unwrap(), another comment coming).

        Maybe I’m wrong, but I understood ‘literally’ in ‘literally never’ in the way young people use it, which doesn’t really mean ‘literally’, and is just used to convey exaggeration.