F#核心库源代码具有用于将元组编译为结构的标志,但我无法使其工作 [英] F# Core library source code has a flag for compiling tuples as structs but I can't make it work

查看:64
本文介绍了F#核心库源代码具有用于将元组编译为结构的标志,但我无法使其工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是对很明显,F#Core库源代码具有一个标志,该标志允许将2元组编译为结构.请参见此处.我做了以下事情:

Apparently, the F# Core library source has a flag that allows 2-tuples to be compiled as structs. See here. I did the following:

  • FSharp.Core.fsprojFSharp.Compiler.fsproj添加了定义TUPLE_STRUXT标志.
  • 内置build.bat.
  • C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\4.3.1.0的内容替换为适当的内置文件.
  • Added a define TUPLE_STRUXT flag to FSharp.Core.fsproj and FSharp.Compiler.fsproj.
  • Built with build.bat.
  • Replaced contents of C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0 and C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\4.3.1.0 with appropriate built files.

我的项目编译并引用了正确的(新建的)FSharp.Core.dll.但是,二元组仍被编译为类.

My project compiles and references the right (newly-built) FSharp.Core.dll. However, 2-tuples are still compiled as classes.

我做错什么了吗?还是这个代码分支实际上是不相关的?元组被编译为System.Tuple而不是此代码中声明的类型(无论是否设置了TUPLE_STRUXT标志)的事实将表明后者.有办法使它起作用吗?

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?

在还设置了标志FX_NO_TUPLE之后,源不编译.我无法解决的错误是prim-types.fs <527,7>: error FS0039: The type 'Struct' is not defined.也就是说,违规行是struct元组定义的第一个:

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?

推荐答案

TUPLE_STRUXT取决于另一个标志,

TUPLE_STRUXT depends on another flag, FX_NO_TUPLE, which should also be set.

这篇关于F#核心库源代码具有用于将元组编译为结构的标志,但我无法使其工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆