Haskell 是否允许在标识符中使用关键字?
如果您在变量名前添加 @,C# 就允许这样做。所以 整数@int = 0; 在 C# 中有效。
Haskell 是否有类似的东西或者它完全不允许这样做?
谢谢
C# allows it if you put an @ before the variable name. So
int @int = 0;
is valid in C#.
Does Haskell have anything similar to this or it doesn't allow it altogether?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有些单词在某些上下文中是关键字,但在其他上下文中可以自由用作标识符,例如
as
和hiding
。C# 的技巧只不过是稍微更改名称,使其不再是关键字。在 Haskell 中,您可以在名称之前或之后放置
_
,或者附加'
。Some words are keywords in some contexts but can be freely used as identifiers in others, such as
as
andhiding
.The C# trick is nothing but just slightly changing the name so that is it no longer a keyword. In Haskell, you could put a
_
before or after the name, or append a'
.看来是不允许的。请注意,您通常可以将
'
放在关键字后面(因为这是有效的标识符字符)并获取非关键字。It appears that it is not allowed. Note that you can usually put
'
after a keyword (since that is a valid identifier character) and get a non-keyword.