F# fsi.ShowDeclarationValues是如何工作的?
根据MSDN文件: 设置为false时,将禁用 在中显示声明值 交互式会话的输出 然而,下面的示例交互会话似乎与该摘要相矛盾F# fsi.ShowDeclarationValues是如何工作的?,f#,f#-interactive,f#-scripting,F#,F# Interactive,F# Scripting,根据MSDN文件: 设置为false时,将禁用 在中显示声明值 交互式会话的输出 然而,下面的示例交互会话似乎与该摘要相矛盾 > let x = 42;; val x : int = 42 > fsi.ShowDeclarationValues <- false;; val it : unit = () > let y = 42;; val y : int >设x=42;; val x:int=42 >fsi.ShowDeclarationValues让y=4
> let x = 42;;
val x : int = 42
> fsi.ShowDeclarationValues <- false;;
val it : unit = ()
> let y = 42;;
val y : int
>设x=42;;
val x:int=42
>fsi.ShowDeclarationValues让y=42;;
val y:int
我没想到上面的最后一行
我误解了什么吗?有人能确认这是否是一个bug吗
谢谢。在我看来,它没有在最后一行显示值,只有绑定的名称和类型。在我看来,它没有在最后一行显示值,只有绑定的名称和类型。Daniel是正确的-这只会禁用值的打印,而不是声明本身 这一点很有用的一种情况是,当您为某个值定义自定义打印机时,该值会创建一个新窗口作为副作用(例如,表示图表或要显示的内容的值) 例如,您可以这样写:
// 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
System.Windows.Forms.MessageBox.Show(s)|>忽略;"")
让a=“foo”//评估此行时不显示消息框
设b=“bar”//(dtto)
a+b/。。但是计算这一行会显示消息框!
Daniel是正确的-这只会禁用值的打印,而不会禁用声明本身
这一点很有用的一种情况是,当您为某个值定义自定义打印机时,该值会创建一个新窗口作为副作用(例如,表示图表或要显示的内容的值)
例如,您可以这样写:
// 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
System.Windows.Forms.MessageBox.Show(s)|>忽略;"")
让a=“foo”//评估此行时不显示消息框
设b=“bar”//(dtto)
a+b/。。但是计算这一行会显示消息框!
啊,现在我明白了。谢谢啊,现在我明白了。谢谢