开发者

Help embedding FSI

开发者 https://www.devze.com 2023-02-22 09:31 出处:网络
Starting here - Embedding F# interactive - I\'ve been trying to embed FSI in my application. However, I\'m getting weird stuff back from StandardOutput.

Starting here - Embedding F# interactive - I've been trying to embed FSI in my application.

However, I'm getting weird stuff back from StandardOutput.

for example, in standard FSI, if I send this:

let a = 3;;

I get this back:

[empty line here]
val a : int = 3
[empty line here]
> |

(with Pi开发者_开发问答pe representing the input position)

But if I send let a = 3;; to StandardInput, I get this back on StandardOutput:

> 
val a : int = 3
|

Has anyone else tried this? Is there something I'm doing wrong, and if not is there any way to work around this? None of the things I've tried so far work, and before I try the 'worse' thing I can think of (set a timer after sending stuff, add the > myself on timeout), I'd like to know if there is a better way!


When embedding F# Interactive, Visual Studio uses the --fsi-server:<some value> parameter. As far as I know, this does two things:

  • Changes the way output is printed (instead of printing >, it prints SERVER-PROMPT> on a separate line, so it should be easier to remove it from the output and detect state when input is expected)

  • It also starts some .NET Remoting channel that you can use to stop execution of commands in F# Interactive (e.g. if it runs into an infinite loop) and it can also provide some completion information.

The F# Interactive pad in MonoDevelop F# plugin uses the flag (see source code on GitHub). I think it works mostly right, but I believe it sometimes prints additional \n in the output.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号