The formatting ist ultimately ugly.
But the code itself is modern and fine.
Am 06.02.2026 um 21:01 schrieb Stefan Ram:
John Ames <commodorejohn@gmail.com> wrote or quoted:
(Correction to my original remark: it looks like lambdas didn't make it
into C23 after all...? I confess I lost track of the discussion at the
time, as I haven't needed any new features in the language since C99
added // comments, declare-anywhere, and stdint.h.)
C++ has had lambdas for ages. Here's a code example from
Sebastian Theophil's Cppcon talk from 2025. (The lambdas
start with the square brackets.)
expected<double, string> parse_and_invert(string_view sv) {
return parse_int(sv).transform(
[](int n) { return n*2; }
).transform_error([](parse_error p) -> string {
switch(p) {
case parse_error::out_of_bounds:
return "out of bounds";
case parse_error::invalid_input:
return "invalid_input";
}
}).and_then(
[](int n) -> std::expected<double, std::string> {
if(0==n) {
return std::unexpected("division by zero");
} else {
return std::expected<double, std::string>(1.0/n);
}
});
}
--- PyGate Linux v1.5.11
* Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)