Indexing access for Lists and Maps considered harmful?

Joseph D. Darcy Joe.Darcy at Sun.COM
Mon Jun 22 12:19:48 PDT 2009


Hello.

A recent blog post cited in Alex Miller's handy "Java 7 Links" 
(http://java7.tumblr.com) claims that adding indexing support for Lists 
and Maps would be harmful because of an arguably surprising behavior on 
compound assignment.  After

map["a"] = map["b"] = "c";

the new value for key "a" would be the old mapping of "b" and not 
necessarily "c" because a call to the put method returns the old value.

I'm not too concerned about this interaction because compound assignment 
is relatively infrequent; however, I think a lint warning from the 
compiler would be appropriate in this case.  Also, an IDE could color 
the non-array uses of "[]" differently to highlight any potential 
differences in semantics.

As a meta-comment, I find it odd that if someone wanted to inform the 
coin discussion he or she would not directly email the coin list in 
addition to or instead of posting a blog entry.

-Joe



More information about the coin-dev mailing list