答复: Shall we add compose/andThen to IntFunction/LongFunction

Brian Goetz brian.goetz at oracle.com
Sun Jun 30 07:16:46 PDT 2013


It depends what you care about most :)

The compose/andThen methods are trivially to manually inline.  Using 
Function<Integer,T> instead of IntFunction will involve more boxing. 
Maybe you care, maybe you don't.  If you don't, compose is fine here. 
If you do, you'll manually inline:

   t -> secondFn.apply(firstFn.apply(t));

On 6/30/2013 9:50 AM, Tristan Yan wrote:
> Does this imply I should use Function<Integer,T> rather than IntFunction<T> if I need do compose/andThen?
> Thank you
>
> -----邮件原件-----
> 发件人: Brian Goetz
> 发送时间: Sunday, June 30, 2013 9:42 PM
> 收件人: Tristan Yan
> 抄送: lambda-dev at openjdk.java.net
> 主题: Re: Shall we add compose/andThen to IntFunction/LongFunction
>
> IntUnaryOperator (int -> int) and friends do.  But the mixed functions like IntFunction<T> (int -> T) would arguably need multiple compose functions for different types, which then ask for overload ambiguities.
>
> On 6/30/2013 4:40 AM, Tristan Yan wrote:
>> I understand why IntFunction/LongFunction doesn't inherit Function, but this makes IntFunction/LongFunction doesn't have compose/andThen methods. Do we have plan to add them?
>>
>>
>>
>> Thank you
>>
>> Tristan Yan(Haibo Yan)
>>
>> Office : 8610-61066212
>>
>> Fax  : 8610-61065441
>>
>> Cell  : 86-18610696822
>>
>>
>>
>> 2F, Building No. 24, Zhongguancun Software Park
>>
>> Haidian District HYPERLINK
>> "http://people.us.oracle.com/pls/oracle/f?p=8000:6:396067987304343:::6
>> :P6_CITY:Beijing"Beijing , 100193
>>
>> oracle
>>
>>
>>
>>
>>
>>


More information about the lambda-dev mailing list