Using keywords as identifiers in F#

2020-01-27 06:01发布

问题:

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#?

回答1:

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.