News for hackers. Stuff that matters.
Re:A Defer Mechanism for C by dooglius on Monday December 14, 2020 @12:40PM (#25420476)
The simple solution to me seems to be to just ban use of loops hierarchically between a defer statement and a guard block. The guard block should definitely be kept as using scope seems like it confuses and complicates the notion of scope; for instance, it seems like a footgun if "if(some condition that turns out to be always true) {blah blah}" can't be refactored into "blah blah". Also, using scope seems to make it difficult to use defer in macros.
Re:A Defer Mechanism for C by gustedt on Monday December 14, 2020 @04:24PM (#25423540)
That is effectively one of the options that is under discussion. One of the advantage of the approach with defer is really that everything happens in the open and all uses that one would want to classify as misuse can easily be flagged by the compiler.