Sujet : Re: ({
De : acm (at) *nospam* muc.de (Alan Mackenzie)
Groupes : comp.lang.c++Date : 22. Mar 2025, 12:26:31
Autres entêtes
Organisation : muc.de e.V.
Message-ID : <vrm6p7$2ue$3@news.muc.de>
References : 1 2 3 4
User-Agent : tin/2.6.4-20241224 ("Helmsdale") (FreeBSD/14.2-RELEASE-p1 (amd64))
Bonita Montero <
Bonita.Montero@gmail.com> wrote:
Am 21.03.2025 um 20:27 schrieb Keith Thompson:
Statement expressions don't compile in *standard* C or C++.
In C++ you could use lambdas for that.
The sort of thing statement expressions are good at are the likes of (C
example):
while ({
ch = getch ();
ch = toupper (ch);
ch != 'Q';
})
switch (ch) {
....
}
, the loop of a command processing function which takes single case
insensitive commands from the keyboard. While it is true that this
example could be rewritten using the comma operator in place of the
statement expression, it would only need to be slightly more complicated
to make this impractical.
Yes, in C++, a lambda could be used instead, but this is somewhat
artificial and would have more boilerplate cluttering up the actual code.
Anyhow, I haven't actually done any real C++ hacking for about 20 years,
I just try to keep Emacs's C++ Mode working.
-- Alan Mackenzie (Nuremberg, Germany).