【问题标题】:emacs F# mode REPL :: using Linqemacs F# 模式 REPL :: 使用 Linq
【发布时间】:2012-08-19 18:40:56
【问题描述】:

我在 Ubuntu 中使用 mono,并按照 here 的说明安装了 F#。 我还安装了fsharp mode for emacs,因此能够测试和编译简单的 F# 程序(都在 emacs F# 模式 REPL 上,还可以生成我在单声道下运行的可执行文件)。

但是,声明:

open System.Xml.Linq

emacs F# 模式 REPL 和从 bash shell 调用 fsharpc 时都失败并出现相同的错误:

error FS0039: The namespace 'Linq' is not defined

我在 SO for C# 中找到了 similar post,尽管使用“-r: System.Xml.Linq”的建议确实适用于从 shell 编译:

fsharpc -r:System.Xml.Linq.dll parseemails.fs 

...我仍然不知道如何使 Linq 命名空间可用于 emacs F# 模式 REPL,因此我可以将它与 C-c C-e 评估一起使用。

【问题讨论】:

  • 使用#r "System.Xml.Linq.dll" 有效吗?

标签: linq emacs f#


【解决方案1】:

正如 John 在评论中提到的,如果您想在 F# 交互中引用程序集(REPL 在 emacs 模式下运行),您可以使用:

#r "System.Xml.Linq.dll"

编译代码时,该命令无效,必须添加命令行参数-r:System.Xml.Linq.dll。如果你想结合两者(交互运行并编译相同的代码),你可以使用条件编译:

#if INTERACTIVE
#r "System.Xml.Linq.dll"
#endif

符号INTERACTIVE是在REPL模式下自动定义的,所以如果你选择并运行这三行,它应该引用程序集(但它不会在编译时破坏你的代码)。

【讨论】:

    猜你喜欢
    • 2017-05-16
    • 1970-01-01
    • 2014-09-03
    • 1970-01-01
    • 2011-10-04
    • 2013-07-16
    • 1970-01-01
    • 1970-01-01
    • 2014-12-23
    相关资源
    最近更新 更多