如何编译具有ML兼容性的F#代码? [英] How do I compile F# code with ML compatibility?

查看:56
本文介绍了如何编译具有ML兼容性的F#代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下F#片段似乎仅在ML兼容模式下编译才有效(在此处运行):

The following F# fragment seems to be valid only if compiled in ML compatibility mode (run it here):

   let i = (1 lxor 5)

但是,我无法在Visual Studio 2012的普通项目中或从命令行使用fsc.exe对其进行编译.我收到错误消息:

However I can't compile it in a trivial project in Visual Studio 2012 or using fsc.exe from the command line. I get the error:

错误FS0039:未定义值或构造函数"lxor"

error FS0039: The value or constructor 'lxor' is not defined

阅读说明的F#规范

尽管F#保留了几个OCaml关键字供将来使用,但/mlcompatibility选项允许将这些关键字用作标识符.

Although F# reserves several OCaml keywords for future use, the /mlcompatibility option enables the use of these keywords as identifiers.

然后将 lxor 列为此类运算符之一.因此,我尝试了命令行 fsc.exe Program.fs --mlcompatibility (版本11.0.60610.1),但仍然收到相同的错误.

It then lists lxor as one such operator. So I tried the command line fsc.exe Program.fs --mlcompatibility (version 11.0.60610.1), but it stil get the same error.

fsc.exe 的文档似乎表明 mlcompatbility 选项仅忽略警告.我没有在fsc的文档中看到任何其他相关选项,也没有在VS中找到实现兼容性的项目选项.

The documentation for fsc.exe seems to indicate that the mlcompatbility option only ignores warnings. I didn't see any other relevant options in fsc's documentation or project options in VS to enable compatibility.

所有其他有关F#/ML兼容性的SO问题似乎都与可以使用哪种语言构造有关,但是我要寻找的只是如何在兼容模式下进行实际编译.我是否必须打开特定的名称空间,引用其他程序集或执行其他操作?

All of the other SO questions about F#/ML compatibility seem to be related to which language constructs can be used, but all I'm looking for is how to actually compile in compatibility mode. Do I have to open a specific namespace, reference another assembly, or do something else?

更新

我还尝试在Ubuntu 13.04的Mono上使用开源编译器 fsharpc (F#3.0).结果与 fsc 相同.

I have also tried using the open source compiler fsharpc (F# 3.0) on Mono on Ubuntu 13.04. The result is the same as fsc.

推荐答案

-mlcompatibility 选项仅关闭警告,因此看起来像是回归.您可以通过在以下位置 https://github.com/fsharp/fsharp/search?q=mlCompatibility&type=Code .

The --mlcompatibility option only turns off warnings, so this looks like a regression. YOu can verify this by searching the source for all references to mlcompatibility here https://github.com/fsharp/fsharp/search?q=mlCompatibility&type=Code.

这篇关于如何编译具有ML兼容性的F#代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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