| Liste des Groupes | Revenir à cl c |
These are more or less real examples, I just simplified the
terms. Here are some from MZLIB:
>
return (status == MZ_OK) ? MZ_BUF_ERROR : status;
>
return (pL == pE) ? (l_len < r_len) : (l < r);
>
sym = (match_dist < 512) ? s0 : s1;
>
return ((pState->m_last_status == TINFL_STATUS_DONE) &&
(!pState->m_dict_avail)) ? MZ_STREAM_END : MZ_OK;
>
I believe that in the first three, all parentheses are superflous, but
they are used anyway. Why is that?
(My preferences for ?: are that the whole thing is syntax, outside of
the precedence scheme, and that it has mandatory parentheses. That
second line would then look like this:
>
return (pL == pE ? l_len < r_len : l < r);
>
There are fewer parentheses in all, and less potential confusion. You
can even have assignments in each branch; they will not interfere with
?:.)
Les messages affichés proviennent d'usenet.