Design for collections upgrades

Brian Goetz brian.goetz at oracle.com
Tue Mar 8 13:10:20 PST 2011


> This would be my preference. Make everything that doesn't need to actually
> iterate lazy by default and do copying at the end if necessary.

We're reluctant to do that, because nothing else in Collections is lazy 
by default.  This is one of the biggest gotchas of LinQ in .NET; the 
queries are lazy, but they sure look eager to the untrained eye, and 
this produces surprising results.  We believe that a big difference like 
eager/lazy should be reflected in the type system, such as by returning 
an abstraction like Stream.  Having some collections be lazy and some be 
eager is asking for trouble...

Further, I think the choice of eager/lazy is a reasonable one to give 
the programmer.  Programmers who do not need the features offered by 
laziness shouldn't need to learn how laziness works just to use the new 
collection operations.


More information about the lambda-dev mailing list