News for hackers. Stuff that matters.
Re:I ruined my vacation by reverse engineering WSC by quietbritishjim on Monday May 12, 2025 @06:38AM (#43961545)
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();});
Re:I ruined my vacation by reverse engineering WSC by junon on Monday May 12, 2025 @08:03PM (#43968584)
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).