F#交互式窗口有什么用处? [英] What is the F# interactive window good for?

查看:274
本文介绍了F#交互式窗口有什么用处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在此处编写宏脚本吗?也许处理一些文字?如果此窗口提供了处理当前文档等的能力,我可能会对F#感兴趣.

Am I able to script macros here? Maybe process some text? I may be interest in learning F# if this window provided the ability to process the current document, etc.

我已经在Google上搜索并找到了有关学习F#,使用F#编写程序的教程,但是关于F#交互式窗口在VS中的优势却一无所获.

I have googled and found tutorials on learning F#, writing programs in F#, but nothing on what the F# interactive window is good for in VS.

听起来像是在咆哮.是吗?不,我喜欢脚本.我只是编写了一个ruby脚本来在许多现有POCO上实现一个接口,但我不容易弄清楚如何使用ReSharper.我当时在想,如果有一个可以与当前文档一起使用的交互式红宝石控制台,它将使这项任务变得更加容易.然后我想到也许F#控制台正是我想要的,并且它正在学习F#.

Sounds like a rant yes. Is it? No. I love scripting. I just wrote a ruby script to implement an interface on a bunch of existing POCO's, that I couldn't easily figure out how to do with with ReSharper. I was thinking that if there was an interactive ruby console that could work with the current document(s) it would have made that task much easier. Then I got thinking that maybe that the F# console was what I was looking for, and it would be learning F# for.

推荐答案

F#Interactive是

F# Interactive is a Read-Eval-Print-Loop (REPL), which is an ad-hoc environment that enables you to experiment with F# code. Many Functional programming languages come with a REPL.

您可以在常规编辑器中突出显示一段F#代码,然后使用 Alt + Enter 将其发送到F#Interactive.您也可以直接在F#Interactive中编写代码.为了聚焦在窗口中,可以使用 Ctrl + Alt + F .

You can highlight a piece of F# code in the normal editor and send it to F# Interactive with Alt+Enter. You can also write code directly in the F# Interactive. In order to focus in the window, you can use Ctrl+Alt+F.

F#Interactive也可以作为命令行程序fsi.exe ,独立于Visual Studio.这样一来,无需访问Visual Studio的人就可以访问F#.

F# Interactive is also available as the command-line program fsi.exe, independent of Visual Studio. This makes F# accessible to people without access to Visual Studio.

还有多种其他方式可以尝试代码和API.我个人比较喜欢使用测试驱动开发(TDD),这是使用REPL的一种替代方法.使用TDD时,我会留下一整套测试,这通常是有益的.但是,单元测试是一个较重"的过程,因为我必须引入一个单元测试框架并编写断言.有时,我只需要尝试各种语法替代方法或建模概念的方法,REPL便提供了更轻巧的替代方法.但是,当我使用F#Interactive时,没有留下任何测试伪像.

There are various other ways to experiment with code and APIs. My personal preference is to use Test-Driven Development (TDD), which is one alternative to using a REPL. With TDD, I leave behind a suite of tests, which can often be beneficial. However, unit testing is a somewhat 'heavier' process, because I have to pull in a unit testing framework, and write assertions. Sometimes, I just need to experiment with various syntax alternatives or ways to model a concept, and the REPL provides more lightweight alternative to that. However, when I use F# Interactive, no test artefacts are left behind.

这篇关于F#交互式窗口有什么用处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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