[nem-en] type inference cannot guess.

mei mei at work.email.ne.jp
Thu May 11 16:21:04 CEST 2006


Hi,

type inference cannot guess this.

-- sample.n
using System;
using System.Collections.Generic;
using System.Query;	// LINQ

def input = $ [1 .. 10] : IEnumerable [int];

// Sequence.Where (IEnumerable<T> source, Func<T, bool> predicate);

mutable output = Sequence.Where (input, x => x % 2 == 0);

--

error message is shown.

l.n:7:18:7:32: error: typing fails on ambiguity between
overloads:
  method System.Query.Sequence.Where(source :
System.Collections.Generic.IEnumeable[T.848], predicate :
System.Query.Func[T.848, int, bool]) :
System.Collectins.Generic.IEnumerable[T.848]
  method System.Query.Sequence.Where(source :
System.Collections.Generic.IEnumeable[T.849], predicate :
System.Query.Func[T.849, bool]) :
System.Collections.Gneric.IEnumerable[T.849]


nemerle needs more information for type inference.

--
// hint (x : int)
mutable output = Sequence.Where (input, x : int => x % 2 == 0);

--

this code is OK.


but C# 3.0 can compile this.

-- sample.cs
using System;
using System.Collections.Generic;
using System.Query;

public class App {
    public static void Main () {
        var input = new [] {1, 2, 3, 4, 5};
        var output = Sequence.Where (input, x => x % 2 == 0);
    }
}

-- 
akiramei <mei at work.email.ne.jp>



More information about the devel-en mailing list