Expression caching

improved version of #9006 (which was an improved version of #8942)
> such expression would result in infinite digest though because we'd
recreate the constant object during each reevaluation.

Actually, that sounds like a problem --- because it sounds like it could break peoples code. I might be missing something, but I don't think we want to not fix that