开发者

Getting Open Namespaces and Modules in an FSI Session

Is there any way to retrieve a list of open namespaces and modules in an FSI Session? I'm playing around with printing an F# quoted expression and I'd like to be able to distinguish between those values of a module which s开发者_如何学Gohould be printed fully qualified versus those which should not.


I don't think there is a way to do this.

The fsi object doesn't have any way of doing that, so the simple approach like this won't work. I believe that internally, the information is stored in the FsiDynamicCompilerState record that F# Interactive uses to keep current state of the interaction (you can find it in "fsi.fs" in the sources).

Unfortunatelly, I didn't find any static property that you could use to access this state - it is kept as a field in FsiDynamicCompiler which is created in the main function and not stored anywhere else. In principle, you may want to be able to access the instance via stack trace (but I couldn't find a way to get local variables of a stack frame).

If you wanted to modify fsi.exe to make this possible, that would be another question, but I suppose that's not what you want.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜