Re: ({

Liste des GroupesRevenir à cl c++ 
Sujet : Re: ({
De : acm (at) *nospam* muc.de (Alan Mackenzie)
Groupes : comp.lang.c++
Date : 22. Mar 2025, 16:20:35
Autres entêtes
Organisation : muc.de e.V.
Message-ID : <vrmkg3$308h$2@news.muc.de>
References : 1 2 3 4
User-Agent : tin/2.6.4-20241224 ("Helmsdale") (FreeBSD/14.2-RELEASE-p1 (amd64))
Scott Lurndal <scott@slp53.sl.home> wrote:
Alan Mackenzie <acm@muc.de> writes:
Paavo Helde <eesnimi@osa.pri.ee> wrote:
On 20.03.2025 20:27, Alan Mackenzie wrote:

It appears the statement expressions are a gcc extension which does not
even compile in standard C++, and is probably not needed for anything in
C++ as there are better options like templated and inlined functions.
In C there might be some usage case for it.

I'm not sure what you meant by templated functions here, but an inline
function has the disadvantage of fragmenting the code.  Rather than have
a few lines of code where they're used, you need to look somewhere else
to see what they do.

An inline function name should be chosen such that it is sufficient to
define exactly what the effect of the function call will be, while
still hiding the implementation and improving readability.

Yes, that's fine in theory.  In practice, meaning while debugging, a
whole lot of midget functions, each called something like
convert_next_char_to_upper_case_is_it_Q_p is a nightmare.  That name is
more difficult to understand than the three lines of code (see another
of my posts in this thread) it replaces.

While debugging, _nothing_ can be trusted to do what it says, and a
hidden implementation makes things worse - rather than having to scroll
a window to the inline function, it's probably in a different file.

Even a single midget function which isn't a coherent thing makes
debugging more irksome than simply having the three lines of code
physically in the larger function where they are actually used.

--
Alan Mackenzie (Nuremberg, Germany).


Date Sujet#  Auteur
20 Mar 25 * ({13Alan Mackenzie
21 Mar 25 +* Re: ({2Bonita Montero
22 Mar 25 i`- Re: ({1Bonita Montero
21 Mar 25 `* Re: ({10Paavo Helde
21 Mar 25  +* Re: ({4Keith Thompson
22 Mar 25  i+* Re: ({2Bonita Montero
22 Mar 25  ii`- Re: ({1Alan Mackenzie
22 Mar 25  i`- Re: ({1Alan Mackenzie
22 Mar 25  +* Re: ({4Alan Mackenzie
22 Mar 25  i+* Re: ({2Paavo Helde
22 Mar 25  ii`- Re: ({1David Brown
22 Mar 25  i`- Re: ({1Alan Mackenzie
1 Apr 25  `- Re: ({1Jakob Bohm

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal