diff --git a/NEWS b/NEWS index 2acd7c50b3..778918e60b 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,12 @@ Zeek 4.1.0 New Functionality ----------------- +- Lambda functions can now use capture-list to help specify exactly which local + variables from outer scopes need to made available while evaluating the lambda + and also the method by which they're made available: deep vs. shallow copy. + + For examples, see: https://docs.zeek.org/en/master/script-reference/types.html#type-function + Changed Functionality --------------------- @@ -21,6 +27,13 @@ Removed Functionality Deprecated Functionality ------------------------ +- Lambda/closure support: automatic capturing of references to variables + outside a lambda's scope is now deprecated. An explicit capture + list which also specifies the desired copy-semantics is now required when + writing lambda functions that refer to local variables of an outer scope. + + For examples, see: https://docs.zeek.org/en/master/script-reference/types.html#type-function + Zeek 4.0.0 ========== diff --git a/src/Expr.cc b/src/Expr.cc index d600ed0718..c148c5538f 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -4429,6 +4429,7 @@ void LambdaExpr::CheckCaptures() { if ( outer_ids.size() > 0 ) { + // TODO: Remove in v5.1: these deprecated closure semantics reporter->Warning("use of outer identifiers in lambdas without [] captures is deprecated: %s%s", outer_ids.size() > 1 ? "e.g., " : "", outer_ids[0]->Name());