F# 标识符、模块、类型和成员名称中允许使用哪些字符?

What characters are allowed in F# identifiers, module, type and member names?

这个问题是关于标识符中的字符,而不是 keywords as identifiers

我找到了 this question on C# names,但在 F# 上找不到相同的东西。通常这几乎不相关,但在我的测试命名中我经常使用点 . 并且很惊讶它在模块名称中不受支持,但在 let-binding 中受支持:

// fails:
module ``Run Test.Me functions`` = 
    [<Test>]
    let ``X.Add should add``() = test <@ X.Add 2 2 = 4 @>

// Succeeds
module ``Run Test-Me functions`` 
    [<Test>]
    let ``X.Add should add``() = test <@ X.Add 2 2 = 4 @>

除了命名测试之外,我看不出这有什么用,但这让我想知道:类型和模块名称支持哪些字符,成员名称和 let 绑定支持哪些字符?

一些测试:

module ``Weird.name`` = ()  // fails
module ``Weird-name`` = ()  // succeeds
module ``Weird()name`` = () // succeeds (?)
module ``Weird*name`` = ()  // fails
module ``Weird+name`` = ()  // fails
module ``Weird%name`` = ()  // succeeds (?)
module ``Weird/name`` = ()  // fails
module ``Weird\name`` = () // fails

所有这些名称都以 let 绑定或成员名称的形式出现,但不以类型名称或模块名称的形式出现。至少这是一致的。但是我在允许的和不允许的方面找不到任何行或逻辑

也许限制是由 CLR/MSIL 而不是 F# 本身强加的?

看看 F# Language Specification 4.0 - 在部分 3.4 Identifiers and Keywords 中。

Note that when an identifier is used for the name of a types, union type case, module, or namespace, the following characters are not allowed even inside double-backtick marks:
., +, $, &, [, ], /, \, *, \", `

除此列表外,任何名称都允许使用 @(at 符号),但会引发警告:

warning FS1104: Identifiers containing '@' are reserved for use in F# code generation

尽我所能找到:

可以在名称为 IllegalCharactersInTypeAndNamespaceNames.

的 F# 编译器中找到字符列表

由于这是用于生成 IL,因此会导致 ECMA-335 - Common Language Infrastructure (CLI) Partitions I to VI 内容为:

II.5.3 Identifiers - Identifiers are used to name entities. Simple identifiers are equivalent to an ID. However, the ILAsm syntax allows the use of any identifier that can be formed using the Unicode character set (see Partition I). To achieve this, an identifier shall be placed within single quotation marks.

ID is a contiguous string of characters which starts with either an
alphabetic character (A–Z, a–z)
or one of _, $, @, ` (grave accent), or ?,
and is followed by any number of
alphanumeric characters (A–Z, a–z, 0–9)
or the characters _, $, @, ` (grave accent), and ?