Treat functions as templates, initial work.

Now generic lambdas are emitted, and auto is used throughout.
Variables are declared but not typechecked in function bodies
(if function was not declared).
Bugfix: check empty() before calling top().
Update examples to match current compiler output.