• Re: C/C++ timeline (was Re: Python: A Little Trick For Every Need)

    From ram@ram@zedat.fu-berlin.de (Stefan Ram) to comp.lang.c++ on Fri Feb 6 20:01:49 2026
    From Newsgroup: comp.lang.c++

    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);
    }
    });
    }


    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From Bonita Montero@Bonita.Montero@gmail.com to comp.lang.c++ on Sat Feb 7 08:27:01 2026
    From Newsgroup: comp.lang.c++

    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);
    }
    });
    }



    --- Synchronet 3.21b-Linux NewsLink 1.2