Look what I found
-
Look what I found
@error Duff's device all over again. Nice!
-
Look what I found
@error /me sets mode = 3, chuckling
-
@error /me sets mode = 3, chuckling
@_the_cloud Yeah, but if you click the link, they actually use default case there.
-
Look what I found
@error I'm calling the police
-
Look what I found
@error that's wild. I wonder how this would be treated by different formatters/style enforcers and if it would break
-
Look what I found
@error At the time this was written (for hardware & compilers were pre SSA) this could have been reasonable.
-
Look what I found
@error yup that's how Contiki implemented Protothreads initially:
-
Look what I found
@error That's super neat, I didn't know! I'll probably use this in my code at a some point...
-
Look what I found
@error this should be classified as an infohazard
-
Look what I found
Three lines too many. I thought serious programmers were lazy.
-
Look what I found
@error It's an utter pain in the arse when writing a compiler too, and even worse is when goto gets involved.
-
@error that's wild. I wonder how this would be treated by different formatters/style enforcers and if it would break
@mikee I actually tried it. It works just fine to my surprise. But the clangd formatter gone mad:
-
@_the_cloud Yeah, but if you click the link, they actually use default case there.
@error @_the_cloud Only in the original example, not in the first two. I'd set it to 3 and chuckle too. I'm an FPGA guy, so I always think about else/default.
-
Look what I found
@error gloop, arfle, barfle says it all.
-
@mikee I actually tried it. It works just fine to my surprise. But the clangd formatter gone mad:
@error ha! Thanks for testing!
-
Look what I found
@error it's beautiful
-
Look what I found
@error reminds me of Duff's Device for abitrary length byte copy using the switch as an index into an architecture-appropriate unrolled loop https://en.wikipedia.org/wiki/Duff%27s_device
-
@error That's super neat, I didn't know! I'll probably use this in my code at a some point...
@vaporeon_ please don't

-
Look what I found
@error I don't think I ever would have tried to pass that off, myself, but I sort of admire the fact that, even though it's language abuse, it produces a predictable outcome. C has a lot of undefined behavior, but somehow, this isn't.
I think I tried to use Duff's Device in a project once, but my colleagues objected and made me change it. Or maybe I just explained Duff's Device to them and they were horrified. Like, "I don't know if I can trust that guy anymore" horrified. It was a long time ago.
This is interesting but it's not really saving a ton of time or code space. I think Duff's Device is probably more defensible.
-
Look what I found