News for hackers. Stuff that matters.
Re:Catch-23: The New C Standard Sets the World on Fire by xigoi on Sunday April 02, 2023 @06:45AM (#35409171)
Yeah, I realize that now. That's even worse. So you'll have to write something like

    int aa,twoa,twoab,bb,aaplustwoab,aaplustwoabplusbb;
    if (ckd_mul(a,a,&aa)) { return error; }
    if (ckd_mul(2,a,&twoa)) { return error; }
    // …
    if (ckd_add(aaplustwoab,bb,aaplustwoabplusbb)) { return error; }
    return aaplustwoabplusbb;
So ergonomic!

> If you're just going to throw out the bool and ignore the overflows, why bother with checked operations in the first place?

I'd expect the functions to return the result on success and crash on failure. Or better, raise an exception, but C doesn't have exceptions…

Re:Catch-23: The New C Standard Sets the World on Fire by chongli on Sunday April 02, 2023 @02:09PM (#35413403)
Why not just write:

    bool aplusb_sqr(int* c, int a, int b) {
        return c && ckd_add(c, a, b) && ckd_mul(c, *c, *c);
    }
Re:Catch-23: The New C Standard Sets the World on Fire by xigoi on Sunday April 02, 2023 @02:14PM (#35413451)
Obviously you could do that in this case, I just wanted to come up with a complicated formula.