Add a memoize function to Function.

This will add a memoization cache to the function, automatically caching
the return value based on the arguments passed in.

The cache identifies arguments by guid, so it is only suitable for
functions where object identity is sufficient to determine the return
value.
Address some code review comments in memoize.