[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bindings and assignments (was: Re: continuations)
> Date: Thu, 14 Aug 2003 10:45:34 -0400
> From: "David B. Tucker" <email@example.com>
> > I imagine, though I don't have statistical evidence, that the
> > requirement of declaring local variables to be final in order to
> > reference them within anonymous inner classes (closures) is almost
> > entirely unknown and unused in practice.
> Out of curiosity, does anyone know why Java only allows final variables
> to be referenced from within anonymous classes?
Otherwise you'd have the equivalent of true closures, and if you had that
java would be a *really* powerful and useful language, so they obviously
couldn't do that.
This is my #1 pet peeve about java. It drives me crazy. So many styles of
programming are made so much harder because of this. But with real
closures, the environment model of java would get more complicated, and
presumably there would be efficiency costs as well, and I assume that the
language's designers didn't want to deal with any of that.