Hacker News new | past | comments | ask | show | jobs | submit login

Typo: in the user code example, I think the second should be in rather than out.

This is pretty cute - looks useful in practice. I think you can slightly enhance the probability of the compiler making the result efficient by using a switch statement, like:

    goto setup1;
    got_value:
    switch (value) {
       setup1: ...setup 1...; goto setup2;
       case 1: ...; break;
    }
etc.

In C++, you could do something fairly equivalent with lambdas, without having to involve the "evil" preprocessor.




Uh, fixed.

Your solution looks a lot like Duff's device :)




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: