Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think the syntax is exactly why they're saying it's cursed. IMO your suggestion is no better - yes it makes defer look like a keyword, but it's not! As I said in a sibling comment, I think it's clearer if you're honest that you're using a macro: DEFER([](){something();});

Or you could even make a non-macro version (but then you need to think of variable names for each defer):

   auto defer_uninitialise = do_defer([](){CoUninitialize();});


Sure, I've used __LINE__ for this before too, and yeah I agree that my keyword construction was too clever (seemed cool at the time, since the macro had a dangling = at the end to make it work).




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

Search: