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#?
Keywords are predefined, reserved words used in programming that have special meanings to the compiler. Keywords are part of the syntax and they cannot be used as an identifier.
Keywords cannot be used as identifiers.
In Python, keywords are the reserved names that are built-in to Python, so a keyword cannot be used as an identifier - they have a special meaning and we cannot use them as identifier names. Special symbols like !, @, #, $, %, etc. are not allowed in identifiers. Python identifiers cannot only contain digits.
No punctuation or special symbol except 'underscore' is used. Examples of keywords are: int, char, if, while, do, class etc. Examples of identifiers are: Test, count1, high_speed, etc.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With