• lambalicious
    link
    fedilink
    English
    arrow-up
    1
    ·
    2 days ago

    Correct me if I’m wrong:

    If a contract has to apply to what it goes inside the body of the function, then it has to go, and be limited to, inside the body of the function. Else we get a longer version of the whole explicit(body_of_function) noexcept(noexcept(body_of_function)) function (arguments_of_function) { body_of_function } decltype(body_of_function) debacle. And, to me, that makes sense: if for example you are only using the fact that a function name exists, but are not invoking it, you only need the declaration, you don’t need any of that added hassle.

    Accepting that a contract can go outside the function, means being able to accept that a user of the function should be able to load only the function and not its contract, for example for no-contract modes, or for compatibility with older compilers. It’s no different from nothrow modes, or accepting that we can #ifdef nonworking pieces of code away.

    • kunaltyagi@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      1 day ago

      And that’s the criticism of current design that it doesn’t address issues like this and feels like half baked from certain pov

      The nothrow (or whatever got deprecated) was a similarly poor design where the headaches weren’t worth the benefits