1) I can't say why it's that way, but it does not shock me much. The way I see it, F# tuples are exposed to other assemblies as .NET4 Tuples when targetting .NET 4 only. The fact that F# tuples are exposed as a particular type to external assemblies does not necessarily imply that they have to be of that type internally too.
Have you tried using "new System.Tuple(...)" to create .NET 4 Tuples, if that's what you want? I do hope that Item properties are accessible then.

2) let _, x, _, _ = t
Maybe not so elegant due to the number of _ symbols, but in many cases one is interested in more than one field anyway, so it's not really a problem. For pairs, you can use fst and snd.

By on 7/14/2010 3:54 AM ()

you can do something like this:

1
2
3
4
5
6
7
8
9
type Tuples private ()= 
    static member Unwrap (x : 'T1 * 'T2) = box x :?> System.Tuple<'T1, 'T2>
    static member Unwrap (x : 'T1 * 'T2 * 'T3) = box x :?> System.Tuple<'T1, 'T2, 'T3>
    static member Unwrap (x : 'T1 * 'T2 * 'T3 * 'T4) = box x :?> System.Tuple<'T1, 'T2, 'T3, 'T4>
    static member Unwrap (x : 'T1 * 'T2 * 'T3 * 'T4 * 'T5) = box x :?>  System.Tuple<'T1, 'T2, 'T3, 'T4, 'T5>
    // ...

let t1 = Tuples.Unwrap((1,2, "3", 4y))
let t2 = Tuples.Unwrap((1,2))

PS:just curious, why do you need that stuff?

PPS: if brackets around actual parameters are omitted, compiler issues a confusing message

error FS0503: The member or object constructor 'Unwrap' taking 1 arguments are not accessible from this code location. All accessible versions of method 'Unwrap' take 1 arguments.

By on 7/14/2010 3:41 AM ()

Thanks. I'd rather use records or pattern matching if that's the best option :)

you can do something like this:
PS:just curious, why do you need that stuff?

Mainly curious about the compiler. But there's cases where one is too lazy to define a record/use PM.

By on 7/14/2010 3:45 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