DoAll() {
// A
a1 = ...
a2 = ...
a3 = ...
// B
b2 = lambda(x,y) {
b1 = f(x)
b2 = g(y)
}(a1,a3);
// C
lambda(x) {
c1 = h(x)
}(b2);
}
I've added explicit intermediates to better visualize where the scope binding happens, but most languages allow the compiler to bind these variables implicitly whenever an anonymous function references variables from outer scope. That helps with readability, but not with scoping.