Re: Opinions on `defer`?

Liste des GroupesRevenir à cl c 
Sujet : Re: Opinions on `defer`?
De : nntp (at) *nospam* fulltermprivacy.com (Phillip)
Groupes : comp.lang.c
Date : 07. Jan 2025, 15:53:57
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vljf65$28dcj$1@dont-email.me>
References : 1 2
User-Agent : Mozilla Thunderbird
On 1/7/25 2:49 AM, David Brown wrote:
On 07/01/2025 01:35, Alexis wrote:
>
Hi all,
>
"Modern C" author Jens Gustedt has been posting on his blog about a
proposed `defer` feature (as provided by e.g. Zig and Go), the most
recent being:
>
   https://gustedt.wordpress.com/2025/01/06/simple-defer-ready-to-use/
>
What do people here think about having such a feature in C?
>
 I've used gcc's "cleanup" attribute a couple of times, typically in connection with somewhat messy stuff hidden behind simple macro names.
 I think "defer" could be useful on occasion, and could sometimes give clearer and safer code than "goto"-based error handling.  But as with any such feature there is a risk of abuse - too many "defers" in a function will make the code as much a spaghetti monster as multiple goto's.  If people use it to keep code neater and reduce the risk of resource leakage, it can be a good thing.  If they use it as an excuse to write even bigger and more illegible functions, it's bad.
 
The latter will always be the case. So you have to decide if adding this is worth the abuse it WILL get. Any ideas that this won't be abused is just naive. The abuse will get worse as time goes on.
--
Phillip Frabott
----------
- Adam: Is a void really a void if it returns?
- Jack: No, it's just nullspace at that point.
----------

Date Sujet#  Auteur
7 Jan 25 * Opinions on `defer`?31Alexis
7 Jan 25 +* Re: Opinions on `defer`?2Kaz Kylheku
8 Jan 25 i`- Re: Opinions on `defer`?1Thiago Adams
7 Jan 25 +* Re: Opinions on `defer`?2David Brown
7 Jan 25 i`- Re: Opinions on `defer`?1Phillip
7 Jan 25 +- Re: Opinions on `defer`?1John McCue
7 Jan 25 +* Re: Opinions on `defer`?4Bonita Montero
8 Jan 25 i`* Re: Opinions on `defer`?3Chris M. Thomasson
9 Jan 25 i `* Re: Opinions on `defer`?2Bonita Montero
11 Jan 25 i  `- Re: Opinions on `defer`?1Bonita Montero
8 Jan 25 +* Re: Opinions on `defer`?3Janis Papanagnou
8 Jan 25 i+- Re: Opinions on `defer`?1Kaz Kylheku
28 Feb 25 i`- Re: Opinions on `defer`?1Lawrence D'Oliveiro
8 Jan 25 +- Re: Opinions on `defer`?1BlueManedHawk
8 Jan 25 `* Re: Opinions on `defer`?17Tim Rentsch
8 Jan 25  +* Re: Opinions on `defer`?3Thiago Adams
8 Jan 25  i+- Re: Opinions on `defer`?1Thiago Adams
19 Feb 25  i`- Re: Opinions on `defer`?1Tim Rentsch
9 Jan 25  +* Re: Opinions on `defer`?4David Brown
9 Jan 25  i`* Re: Opinions on `defer`?3Kaz Kylheku
9 Jan 25  i `* Re: Opinions on `defer`?2David Brown
9 Jan 25  i  `- Re: Opinions on `defer`?1Michael S
9 Jan 25  `* Re: Opinions on `defer`?9Bonita Montero
9 Jan 25   `* Re: Opinions on `defer`?8Bonita Montero
10 Jan 25    +* Re: Opinions on `defer`?2Bonita Montero
11 Jan 25    i`- Re: Opinions on `defer`?1Bonita Montero
10 Jan 25    +- Re: Opinions on `defer`?1David Brown
13 Jan 25    +* Re: Opinions on `defer`?2Tim Rentsch
13 Jan 25    i`- Re: Opinions on `defer`?1Bonita Montero
24 Feb 25    `* Re: Opinions on `defer`?2Lawrence D'Oliveiro
3 Mar 25     `- Re: Opinions on `defer`?1Bonita Montero

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal