I think the scope of the variable lifetime should be the object the function is in.
Ie,
class Foo { int foo(int a) { function f=lambda() { static int x=0; x++; return x+a; }; return f(); } }
the variable x should still be stored in the object defined by the class.
It should work well defining the scope with a parenthesis, like
static(object) // closest object parent static(global) // totally global, same for each instance of the object static(parent) // closest parent static(<name>) static(foo) // stored with parent function above static(Foo) // stored with parent object above