Expected distribution of lambda sizes (Re: Syntax poll, take 2)

John Nilsson john at milsson.nu
Wed Jun 15 11:43:58 PDT 2011


Of course the interesting difference is between theese two

interface GenericSAM {
  <T> T m(Pair<?,T> p);
}

interface RawSAM {
  Object m(Pair p);
}

BR,
John

On Wed, Jun 15, 2011 at 8:05 PM, Maurizio Cimadamore
<maurizio.cimadamore at oracle.com> wrote:
> On 15/06/11 18:43, John Nilsson wrote:
>>
>> On Wed, Jun 15, 2011 at 7:39 PM, Maurizio Cimadamore
>> <maurizio.cimadamore at oracle.com>  wrote:
>>>
>>> *) Pair#fst is compatible with a SAM type whose method is m(Pair)
>>> *) Pair<>#fst is compatible with a SAM type whose method is of the kind
>>
>> Ah, there you go. Forgot about this "interesting" aspect of the type
>> system.
>>
>> Is it reasonable though? When would it, in practice, be important to
>> enforce this difference?
>>
>> BR,
>> John
>
> class Pair<X,Y> {
>  X fst() { return null; }
>  Y snd() { return null; }
> }
>
> interface SAM {
>   Integer m(Pair<Integer,String> p);
> }
>
> interface RawSAM {
>   Object m(Pair p);
> }
>
> class Test {
>
> static void call(SAM s) { System.out.println("1"); }
> static void call(RawSAM s) { System.out.println("2"); }
>
> public static void main(String[] args) {
>   call( Pair<Integer,String>#fst ); //prints 1
>   call( Pair#fst ); //prints 2
> }
>
> }
>
> Maurizio
>


More information about the lambda-dev mailing list