开发者

Does Haskell allow use of keywords in identifiers?

开发者 https://www.devze.com 2023-02-13 12:32 出处:网络
C# allows it if you put an @ before the variable name. So int @int = 0; is valid in C#. Does Haskell have anything similar开发者_JAVA百科 to this or it doesn\'t allow it altogether?

C# allows it if you put an @ before the variable name. So int @int = 0; is valid in C#.

Does Haskell have anything similar开发者_JAVA百科 to this or it doesn't allow it altogether?

Thanks


Some words are keywords in some contexts but can be freely used as identifiers in others, such as as and hiding.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消