Sujet : Re: Opinions on `defer`?
De : david.brown (at) *nospam* hesbynett.no (David Brown)
Groupes : comp.lang.cDate : 10. Jan 2025, 19:13:16
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vlrnvs$5nls$1@dont-email.me>
References : 1 2 3 4 5 6
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0
On 09/01/2025 19:23, Scott Lurndal wrote:
Bonita Montero <Bonita.Montero@gmail.com> writes:
Am 09.01.2025 um 17:41 schrieb Scott Lurndal:
>
Why ?
>
If you want destructors, use c++.
>
If you're stuck with plain C, something like defer would
be a huge relief over gotos as used in the Linux kernel.
Most C-code can be compiled with a C++ compiler, and
one can selectively use certain C++ features, such as
destructors.
I don't find the 'defer' proposal readable and I suspect it
may lead to more maintainability issues that simple gotos.
A new feature - or "advanced" macro (as distinct from a little function-like macro or a literal or constant value) - will always have maintainability issues as developers will be unfamiliar with it.
But a big potential benefit from a "defer" feature (or scope-guard template in C++) comes when replacing /complicated/ gotos, not simple ones.