• quarterstar@lemmy.worldOP
    link
    fedilink
    English
    arrow-up
    1
    ·
    25 days ago

    This is the first article that I write of this type, so I tried to create a balance between implementation and explanation without making the latter strictly dominate the pacing. If anyone has feedback I’d appreciate!

  • BB_C@programming.dev
    link
    fedilink
    arrow-up
    2
    arrow-down
    1
    ·
    25 days ago

    I didn’t read your post. But note that ? depends on traits /type classes with associated types (Try, FromResidual, and From), and is often implemented for sum types (e.g. Result, Option) with at least two variants containing Output and Residual type values.

    The FromResidual part does value conversion for the Residual, which is how you e.g. get auto-converted error values matching the return Result value. These converted error values are often themselves contained in variants in an enum/sum Error type.

    So neither an actual equivalent in C++ is possible, due to type system limitations/differences, nor whatever you tried to do is an apples-to-apples match, or even represents two fruits from the same basket.

    • quarterstar@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      25 days ago

      Yeah I didn’t mean a one-to-one implementation in the pedantic sense; I meant more like how it would be implemented to address certain issues in C++ that I demonstrated at the beginning. Sorry if I wasn’t clear with the article.