Functions that return Functions - Closures

There's a good example here: http://pub.vestasys.org/cgi-bin/vestaweb?path=/vesta/vestasys.org/bridges/env_build/1/build.ves&hilight=1 line 169 :

/**nocache**/
build_X_delayed(f)(l:list(text))() { return ./$f(l); };

build_root_delayed = build_X_delayed("build_root");
build_addon_root_delayed = build_X_delayed("build_addon_root");
build_envVars_delayed = build_X_delayed("build_envVars");
build_root_and_envVars_delayed = build_X_delayed("build_root_and_envVars");

the double paren thing lets you call the func with just the first param, and it returns a another function with the first param set to that. You can now call this second function with the remaining param(s).

So, in the above example, now one could call build_root_delayed :

./root = build_root_delayed(<...>);

build_X_delayed will now be called with the f param bound to "build_root".