F#命名规则 [英] F# naming convention

查看:159
本文介绍了F#命名规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有F#的一个官方的命名/套约定?

Is there an "official" naming / casing convention for F#?

我一直在使用C#风格与否的疑问:

I'm always in doubt of using C# style or not:

Class.MyFunctionName or Module.my_function_name

在F#你的意思混合BCL类和F#库的人:他们有不同的外壳和code看起来很丑陋

In F# you're meant to mix BCL classes and F# library ones: they have different casing and the code looks very ugly.

推荐答案

是的,有困惑,因为F#从OCaml的蜕变到.NET多年。基本上,命名约定是一个重大更改 - 旧的code是新的code不一致

Yes, there is confusion, because F# has morphed from OCaml to .Net over the years. Basically, the naming conventions are a "breaking change" - old code is inconsistent with new code.

然而,2009年5月CTP版已经解决了这个问题。

However, the May 2009 CTP has settled the issue.

的<一个href="http://blogs.msdn.com/dsyme/archive/2009/05/20/detailed-release-notes-for-the-f-may-2009-ctp-update-and-visual-studio-2010-beta1-releases.aspx">Release注说......

标准库命名约定

对于在F#库所采用的命名约定如下:

The naming conventions adopted for the F# library are as follows:

      
  • 所有.NET和F#OO code使用PascalCase根据现有的.NET指南

  • All .NET and F# OO code uses PascalCase according to existing .NET guidelines

在F#函数式编程运算符,如List.map是在F#中内部实现code使用。这种code采用驼峰的运营商名称

The F# functional programming operators such as List.map are for use in F# internal implementation code. This kind of code uses camelCase for operator names

下划线不应使用。

那么,你的问题...

Class.MyFunctionName or Module.my_function_name

答案是:

Class.MyFunctionName和Module.MyFunctionName

Class.MyFunctionName and Module.MyFunctionName

(将上面的规则1)。

(applying rule 1 above).

还有一些混乱通过比较与F#的编程操作(如List.averageBy),但生产的F#code应该使用驼峰,因此看起来像其他人一样的.Net code。如果有疑问,请检查<一href="http://$c$c.msdn.microsoft.com/fsharpsamples/Release/ProjectReleases.aspx?ReleaseId=2705">sample code 的CTP。

There is still some confusion by comparision with the F# programming operators (eg. List.averageBy), but production F# code should use CamelCase, and thus look like everyone else's .Net code. If in doubt, check the sample code for the CTP.

(我个人like_the_caml_style,但我必须GetOverThat)

(I personally like_the_caml_style, but I'll have to GetOverThat)

这篇关于F#命名规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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