New
Joshua Bloch
jjb at google.com
Mon Mar 29 08:00:31 PDT 2010
Howard,
On Mon, Mar 29, 2010 at 3:39 AM, Howard Lovatt <howard.lovatt at gmail.com>
wrote:
This group has also commented on the undesirability of Integer interning for
some values and not others.
I don't think that's the problem so much as the fact that the spec mandates
which values must be interned. This causes people to write unreadable and
unmaintainable programs that take advantage of those guarantees. I with the
JLS had merely suggested that implementations might want to cache and reuse
common values as a quality-of-service issue. So I see this as a case of
overspecification, rather that an inherently bad idea. As I said a while
back, I believe the same behavior is appropriate for lambdas: the
specification should not mandate the creation of an object each time a
lambda expression is evaluate, and should note (using non-normative text),
that implementers should avoid creating such objects when it results in
improved performance.
Regarding the desirability of using the "new" keyword for lambdas (a purely
syntactic decision): Even if each evaluation of a lambda expression did
result in the creation of a new object, a primary raison d'etre for lambdas
in Java is economy of expression. The "new" keyword (preceded and followed
by a space) is detrimental to that goal.
Josh
More information about the lambda-dev
mailing list