Extend function() to support an optional closure argument.

Also, simplify some ref counting for other optional arguments.
2 files changed