Changes between Version 3 and Version 4 of C++Features


Ignore:
Timestamp:
Aug 12, 2025, 2:39:27 PM (2 months ago)
Author:
pett
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • C++Features

    v3 v4  
    3232
    3333[https://www.stroustrup.com/C++11FAQ.html#raw-strings More discussion]
     34
     35== Humongous Lambdas ==
     36
     37It just didn't occur to me that lambdas could be more than short anonymous functions handled off as arguments to other functions, ''e.g.'':
     38
     39{{{
     40    // as_term
     41    spec_parser["as_term"] = [](const SemanticValues &vs) {
     42        auto objects_inst = std::any_cast<PyObject*>(vs[0]);
     43        if (vs.choice() == 1) {
     44            // tilde
     45            auto ret = PyObject_CallMethodObjArgs(objects_inst, invert_arg, session, models, nullptr);
     46            if (ret == nullptr)
     47                throw std::logic_error(use_python_error);
     48            Py_DECREF(ret);
     49            outermost_inversion = true;
     50        } else
     51            outermost_inversion = false;
     52        if (vs.size() == 1)
     53            return objects_inst;
     54
     55        // there's a zone selector
     56        return process_zone(std::any_cast<PyObject*>(vs[0]), vs[1]);
     57    };
     58}}}