| 34 | |
| 35 | == Humongous Lambdas == |
| 36 | |
| 37 | It 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 | }}} |