Re: So You Think You Can Const?

Liste des GroupesRevenir à cl c 
Sujet : Re: So You Think You Can Const?
De : julio (at) *nospam* diegidio.name (Julio Di Egidio)
Groupes : comp.lang.c
Date : 10. Jan 2025, 00:37:56
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vlpmkm$2dkpd$16@dont-email.me>
References : 1 2 3 4 5 6 7 8 9
User-Agent : Mozilla Thunderbird
On 10/01/2025 00:23, Ben Bacarisse wrote:
Julio Di Egidio <julio@diegidio.name> writes:
 
On 09/01/2025 02:09, Ben Bacarisse wrote:
Julio Di Egidio <julio@diegidio.name> writes:
>
static AvlTree_t const *AvlTree_node(
      void const *pk, AvlTree_t const *pL, AvlTree_t const *pR
) {
      AvlTree_t *pT;
>
      pT = malloc(sizeof(AvlTree_t));
>
      if (!pT) {
          return NULL;
      }
>
      pT->pk = pk;
      pT->pL = pL;
      pT->pR = pR;
>
      return pT;
}
Just on a side issue, I prefer to make tests like this positive so I'd
write:
   static AvlTree_t const *AvlTree_node(
       void const *pk, AvlTree_t const *pL, AvlTree_t const *pR
   ) {
       AvlTree_t *pT = malloc(*pT);
         if (pT) {
           pT->pk = pk;
           pT->pL = pL;
           pT->pR = pR;
       }
       return pT;
   }
I'm not going to "make a case" for this (though I will if you want!) --
I just think it helps to see lots of different styles.
>
That is *more* error prone,
 I would be happy for you to expand on why you say that.
 
all the more so if it's not a 5 liner...
There is no such thing as expanding 40 years of professional experience in software engineering and programming and doing it properly since day one: just think about that code and what I said for what it's worth, in particular I haven't mentioned 5 liners by chance, things are quite more complicated not in vitro.
And please do not hold a grudge about that: it's not me who was trying to say how to write code... ;)
HTH,
-Julio

Date Sujet#  Auteur
24 Feb 26 o 

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal