Effectively final effective?

Neal Gafter neal at gafter.com
Wed Feb 24 16:34:33 PST 2010


On Wed, Feb 24, 2010 at 3:37 PM, Lawrence Kesteloot <lk at teamten.com> wrote:
> The "final" modifier has bugged me in the past with anonymous inner
> classes, but we really have no experience allowing large number of
> programmers to write code without the restriction. For all we know it
> would cause more confusion or more errors.

Scala and C# and Ruby programmers, and programmers in many other
languages, live without this restriction.  Perhaps we should ask them.
 In my experience it is a blessing compared to the Java alternatives.

One common pattern I've seen is the equivalent of

Type1 result1 = null;
Type2 result2 = null;
doSomeApi(#(){ result1 = someComputation(); result2 = otherComputation(); });
doSomethingWith(result1, result2);

where doSomeApi might be something like Java's
AccessController.doPrivileged(PrivilegedAction).

Cheers,
Neal


More information about the lambda-dev mailing list