问题
This is follow-up question to this proposal.
Apparently, the F# Core library source has a flag that allows 2-tuples to be compiled as structs. See here. I did the following:
- Added a define
TUPLE_STRUXT
flag toFSharp.Core.fsproj
andFSharp.Compiler.fsproj
. - Built with
build.bat
. - Replaced contents of
C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0
andC:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\4.3.1.0
with appropriate built files.
My project compiles and references the right (newly-built) FSharp.Core.dll
. However, 2-tuples are still compiled as classes.
Am I doing something wrong? Or is this code branch in fact irrelevant? The fact that tuples are compiled to System.Tuple and not the type declared in this code (whether the TUPLE_STRUXT
flag is set or not) would indicate the latter. Is there a way to make it work?
EDIT: After also setting the flag FX_NO_TUPLE
the source does not compile. The error I can't get around is prim-types.fs <527,7>: error FS0039: The type 'Struct' is not defined
. That is, the offending line is the first one of the struct tuple definition:
[<Struct>]
type Tuple<'T1,'T2> =
new (v1,v2) = { Item1 = v1; Item2 = v2 }
val Item1 : 'T1
val Item2 : 'T2
Does anyone know what causes this?
回答1:
TUPLE_STRUXT
depends on another flag, FX_NO_TUPLE, which should also be set.
来源:https://stackoverflow.com/questions/24993904/f-core-library-source-code-has-a-flag-for-compiling-tuples-as-structs-but-i-can