Comment

Comment by win311fwg

Why no tagged unions in the C version?

   typedef struct {
        _Bool ok;
        union {
            double value;
            int error;
        };
    } Result_double;

    Result_double x = strtod·or·error(s, NULL);

    if (!x.ok) {
        handle(x.error);
        return;
    }

    use(x.value);
parent win311fwg 20 days ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton