fsi.ShowDeclarationValues如何工作? [英] How does fsi.ShowDeclarationValues work?

查看:68
本文介绍了fsi.ShowDeclarationValues如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据MSDN文档:

设置为false时,禁用 在中显示声明值 交互式会话的输出.

When set to false, disables the display of declaration values in the output of the interactive session.

但是,以下示例交互式会话似乎与该摘要矛盾.

However, the following sample interactive session seems to contradict that summary.

> let x = 42;;

val x : int = 42

> fsi.ShowDeclarationValues <- false;;

val it : unit = ()

> let y = 42;;

val y : int

我没想到上面的最后一行.

I was not expecting the last line above.

我误解了吗?谁能确认这是否是错误?

Have I misunderstood something? Can anyone confirm if this is a bug?

谢谢.

推荐答案

Daniel是正确的-这会禁用仅打印而不打印声明本身.

Daniel is correct - this disables just printing of the values and not the declarations themselves.

一种有用的情况是,当您为自定义打印机定义一个值以创建一个新窗口作为副作用(例如,代表图表或您要显示的值的值)时.

One situation where this is useful is when you define some custom printer for a value that creates a new window as a side-effect (e.g. a value that represents a chart or something you want to display).

例如,您可以这样写:

// Display all evaluated strings in a message box
fsi.ShowDeclarationValues <- false
fsi.AddPrinter(fun (s:string) -> 
  System.Windows.Forms.MessageBox.Show(s) |> ignore; "")

let a = "foo" // Evaluating this line doesn't show message box
let b = "bar" // (dtto)
a + b         // .. but evaluating this line shows the message box!

这篇关于fsi.ShowDeclarationValues如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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