list literal gotcha and suggestion

Gene Ray evildeathmath at
Tue Sep 29 12:07:07 PDT 2009


In my experience, Sets are not rare in well-written code; they're only rare in code where for whatever reason the developer has refused to use them, and instead expends effort and CPU time iterating through an array or ArrayList to achieve the equivalent functionality.  Encouraging this sort of behavior further by including only Lists in the new syntax is not a good plan.

--- On Tue, 9/29/09, Reinier Zwitserloot <reinier at> wrote:

From: Reinier Zwitserloot <reinier at>
Subject: Re: list literal gotcha and suggestion
To: "Mark Thornton" <mthornton at>
Cc: coin-dev at
Date: Tuesday, September 29, 2009, 7:52 AM

new HashSet<>(["a", "b", "c"]);

is too much effort in the rare cases where you need to initialize a  
set-typed parameter? This is java, not perl. Golfing isn't the end goal.

  --Reinier Zwitserloot

On 2009/29/09, at 09:42, Mark Thornton wrote:

> Reinier Zwitserloot wrote:
>> So, let's turn this argument on its head: Why are we trying so hard  
>> to  make set literals work? Why don't we just remove them from the   
>> proposal? The need for them seems minor compared to lists. When  
>> the  collection size is small (below about a 100), O(1) lookup  
>> performance  is irrelevant (and even if it was relevant, due to the  
>> extra
> So that we can supply them as arguments to methods that take a Set  
> and onot a List or Collection, or to initialise Set typed fields.
> Mark Thornton


More information about the coin-dev mailing list