Design for collections upgrades

Rémi Forax forax at univ-mlv.fr
Mon Mar 14 09:15:25 PDT 2011


No deforestation is when you do remove intermediary step
between transformations.

by example reverse(reverse) => identity

or in Java, map(#{ s - > s.toUpperCase() }).map(#{ s -> s.length() })
can be transformed to map(#{ s -> s.toUpperCase().length() })
and then to map(#{ s -> s.length() }

It remember my master thesis on attributed grammars
which is an intermediary representation that can be used
to do this kind of transformation.

Rémi

On 03/14/2011 05:07 PM, John Nilsson wrote:
> Isn't that what they call Deforestation[1]?
>
> BR,
> John
>
> [1] http://en.wikipedia.org/wiki/Deforestation_(computer_science)
>
> On Mon, Mar 14, 2011 at 4:59 PM, Rémi Forax<forax at univ-mlv.fr>  wrote:
>> On 03/14/2011 04:21 PM, Rémi Forax wrote:
>>> On 03/14/2011 04:06 PM, Sam Pullara wrote:
>>>> Ah, the intermediate Iterable. Too early :)
>>>>
>>>> Sent from my iPhone
>>> Yes !
>>> I've just thought that it's a good candidate for escape analysis :)
>>>
>>> Rémi
>>>
>> I've found a trick to be as fast the foreach version if
>> there is only one filter, one mapper or a combination of
>> one filter followed by one mapper.
>>
>> Basically, in the intermediary iterable, you can override
>> reduce() and to() and write a version with a foreach :)
>>
>> Rémi
>>
>>
>>



More information about the lambda-dev mailing list