[Prev][Next][Index][Thread]
Re: Closures
On Fri, 10 Aug 2001 06:45:01 -0400 (EDT), Jeffrey Siegal <jbs@quiotix.com>
wrote:
> Jeff Dalton wrote:
> > I suspect the reason's the same as in Java (where you can do the Java
> > equiv of closing over variables only if they're "final") - there's an
> > easy implementation if you copy bindings instead of sharing them, and
> > you can hide the semantic difference by forbidding assignment.
>
> This is only true in Java for local variables. Fields in a surrounding
> scope are still shared and mutable.
>
> It was never clear to my why this was done for Java. It would not have
> been very hard for the compiler to rewrite the function to replace local
> variables with length-one arrays and then pass those. Whatever.
Which is of course what programmers do manually to pass state back out in
Java.
__Jason
References: