How does fsi.ShowDeclarationValues work?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 04:10:09

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).

For example, you could write this:

// 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!

Looks to me that it didn't show the value in the last line, only the name and type of the binding.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!