Search code examples
f#keywordidentifier

Using keywords as identifiers in F#


In C#, I can do the following:

int @private = 15;

And in VB.NET, I can do the following:

Dim [Private] As Integer = 15

I am wondering if there is a way in F# to use reserved keywords as identifiers, like there is in VB.NET and C#?


Solution

  • Given section 3.4 of the F# 2.0 spec:

    Identifiers follow the specification below. Any sequence of characters that is enclosed in double-backtick marks (`` ``), excluding newlines, tabs, and double-backtick pairs themselves, is treated as an identifier.

    I suspect you can put it in backticks:

    ``private``
    

    I haven't tried it though.