I'm pretty sure that this is an artifact of .NET method interop. When you call a non-F# .NET method syntactically, the tuple syntax is a bit special. By using a syntactic tuple when you call the method, you're specifying multiple arguments.

So, it sees (read1, read2), and figures you're calling an overload with 2 parameters, both ints. This fails.

Hence, double parens shows that the first argument is a real tuple, not the special syntactical one used for calling.

It also works if you pass a tuple value to TryGetValue:

1
2
let pair = 1,2
edges.TryGetValue pair // this is fine
By on 5/15/2009 11:32 AM ()

Then why does not here the compiler thinks that Add is an overload with two integer parameters? This works fine:
let tuples = new System.Collections.Generic.List <int * int> ()
tuples.Add (1,1)

I thought, maybe, even this would work:
tuples.Add 1,1
but it does not.

By on 5/15/2009 10:07 PM ()

Well, I am not completely sure. My _guess_ is that Add only takes a single item, and TryGetValue takes 2, in .NET. One of them is an out parameter. So perhaps that interop stuff produces that syntax.

I would suggest that you send this to fsbugs@microsoft.com to get a solid response and have them ensure it is by design and clarify.

By on 5/16/2009 6:39 AM ()

Another parentheses issue, would have submitted it to fsbugs if I were sure - I am rather new to F#. Other Array methods work fine without their parameters parenthesized. Also, the error method looks strange: "The member or object constructor 'AddAfter' taking 2

arguments is not accessible from this code location. All accessible

versions of method 'AddAfter' take 2 arguments". Output from VS2010 Beta1, running under Vista 64 bit.

> let front = new LinkedList <int> ();;

val front : LinkedList<int>

> front.AddFirst 0;;
val it : LinkedListNode<int> =
System.Collections.Generic.LinkedListNode`1[System.Int32] {List = seq [0];
Next = null;
Previous = null;
Value = 0;}
> front.AddAfter it 2;;

front.AddAfter it 2;;
^^^^^^^^^^^^^^^^^

stdin(29,1): error FS0191: The member or object constructor 'AddAfter' taking 2 arguments is not accessible from this code location. All accessible versions of method 'AddAfter' take 2 arguments
> front.AddAfter (it, 2);;
val it : LinkedListNode<int> =
System.Collections.Generic.LinkedListNode`1[System.Int32]
{List = seq [0; 2];
Next = null;
Previous = System.Collections.Generic.LinkedListNode`1[System.Int32];
Value = 2;}
>

By on 5/21/2009 1:35 AM ()

I think you always need to call .NET methods as tupled methods. The error message could probably be a bit more clear, though. Try getting the new F# (1.9.6.16) and see if it's any better. Otherwise just email them with your observations on it.

By on 5/21/2009 1:39 AM ()

It's the new F# (boxed with the latest Beta). Array.init, for example works just fine without being called with a tuple.

By on 5/21/2009 1:41 AM ()

Array.init is an F# function that's "curried". The .NET methods like the ones on System.Collections.Generic classes are C# method members and are "tupled". IntelliSense should make it clear which is which. A function will have a form like:

1
2
3
4
 

'a -> 'b -> 'c

Whereas a C# method will usually be like:

1
('a * 'b) -> 'c
By on 5/21/2009 1:50 AM ()

Thanks, it makes sense to me now.

By on 5/21/2009 8:48 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper