Design for collections upgrades

Stephen Colebourne scolebourne at joda.org
Tue Mar 8 15:49:37 PST 2011


On 8 March 2011 23:23, Ola Bini <ola.bini at gmail.com> wrote:
>> A better argument against making filter() return a stream is that it's
>> unexpected. The verb "filter" means "filter", not "create a stream
>> that when later evaluated will filter." You can imagine users putting
> I personally am a fan of this argument. I ended up using the past tense
> for lazy sequences in Ioke for this specific reason. It becomes
> immediately obvious if you're in strict or lazy-land based on the tense
> of the method names. To Brian's argument, the type system will tell you
> too, but that's not always apparent from reading a specific line of code.

Sounds like a coding style I've used:
 list.filter(predicate)  // alters list itself
 list.filtered(predicate)  // returns a new list

This chimes with the use of past tense in JSR-310, Joda-Time and similar.

Stephen


More information about the lambda-dev mailing list