在 F# 中使用关键字作为标识符 [英] Using keywords as identifiers in F#

查看:40
本文介绍了在 F# 中使用关键字作为标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 C# 中,我可以执行以下操作:

In C#, I can do the following:

int @private = 15;

在 VB.NET 中,我可以执行以下操作:

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

Dim [Private] As Integer = 15

我想知道 F# 中是否有一种方法可以使用保留关键字作为标识符,就像在 VB.NET 和 C# 中一样?

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

推荐答案

Given F# 2.0 规范的第 3.4 节:

标识符遵循以下规范.任何包含在双反引号 (`` ``) 中的字符序列,不包括换行符、制表符和双反引号对本身,都被视为标识符.

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``

我还没试过.

这篇关于在 F# 中使用关键字作为标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆