neal at gafter.com
Wed Dec 30 13:57:47 PST 2009
On Wed, Dec 30, 2009 at 1:45 PM, Peter Levart <peter.levart at gmail.com> wrote:
> Isn't it true that method 'four' only calls lambda 'two' once? Lambda
> 'two' returns from method 'four' (since lambda is transparent) before
> the second call.
Right (I stand corrected): four() returns 2 on its first invocation,
and throws an exception on subsequent invocations.
> My question was about how can a program differentiate multiple
> invocations of a method from the same call site? Does it maintain a
The javac compiler can use any technique suitable for implementing
these semantics. A counter would work if there were some way to avoid
having to worry about the value wrapping. When a closure captures
some context from the enclosing scope, that context can be packaged up
into a frame object. The identity of that frame object can be used to
distinguish one invocation from another.
More information about the closures-dev