This question is about characters in identifiers, not keywords as identifiers.
I found this question on C# names, but couldn't readily find the same on F#. Normally this is hardly relevant, but in my tests naming I often use the dot .
and was surprised it wasn't supported in a module name, but is supported in a 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 @>
Outside of naming tests I don't see much use for this, but it made me wonder: what characters are supported by type and module names, and what characters for member names and let bindings?
Some tests:
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
All of these name succeed in a let-binding or member name, but not as a type name or module name. At least that is consistent. But I can't find any line or logic in what is allowed and what not
Perhaps the limitation is imposed by the CLR / MSIL and not by F# itself?
Take a look at the F# Language Specification 4.0 - In section
3.4 Identifiers and Keywords
.In addition to this list, the
@
(at-sign) is allowed in any name, but will raise a warning:As near as I can find:
The list of characters can be found in the F# compiler with the name IllegalCharactersInTypeAndNamespaceNames.
As this is used for generating IL, that leads to ECMA-335 - Common Language Infrastructure (CLI) Partitions I to VI which reads: