[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bindings and assignments (was: Re: continuations)

   Date: Thu, 14 Aug 2003 08:05:44 -0700
   X-Authentication-Warning: orchestra.cs.caltech.edu: mvanier set sender to 
mvanier@cs.caltech.edu using -f
   From: Michael Vanier <mvanier@cs.caltech.edu>
   To: dbtucker@cs.brown.edu
   Cc: dherman@ccs.neu.edu, sk@cs.brown.edu, ll1-discuss@ai.mit.edu
   Subject: Re: bindings and assignments (was: Re: continuations)
   > Date: Thu, 14 Aug 2003 10:45:34 -0400
   > From: "David B. Tucker" <dbtucker@cs.brown.edu>
   > > 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?
   > Dave
   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. 

Actually, the prototype implementation *did* allow non-final
variables to be referenced from within inner classes.  There was
an outcry from *users*, complaining that they did not want this!
The reason was interesting: in order to support such variables,
it was necessary to heap-allocate them, and (at that time, at least)
the average Java programmer was still pretty skittish about heap
allocation and garbage collection and all that.  They disapproved
of the language performing heap allocation "under the table" when
there was no occurrence of the "new" keyword in sight.

Maybe we could lift that restriction in the next few years...
I dunno.

--Guy Steele