douchao1864 2015-11-26 22:31
浏览 136
已采纳

Go(golang)是否实际上允许在变量名中使用unicode字符?

Or is that a myth? Can't see it mentioned in any official documentation (it's there, D'oh!) – it sure doesn't seem to work for me when using Atom with the go-plus package. It's a shame as I am doing a lot of math operations, and I love mathematic notation.

Update: I don't consider any mathematical symbol as esoteric: ‖ ⏋∪
Compared to any emoji:

  • 写回答

3条回答 默认 最新

  • doufeinai6081 2015-11-26 22:37
    关注

    Go supports some of the Unicode categories as per https://golang.org/ref/spec#Identifiers

    Identifiers name program entities such as variables and types. An identifier is a sequence of one or more letters and digits. The first character in an identifier must be a letter.

    identifier = letter { letter | unicode_digit } .
    

    The above classes are defined in the spec as:

    unicode_letter = /* a Unicode code point classified as "Letter" */ .
    unicode_digit  = /* a Unicode code point classified as "Decimal Digit" */ .
    

    In The Unicode Standard 6.3, Section 4.5 "General Category" defines a set of character categories. Go treats those characters in category Lu, Ll, Lt, Lm, or Lo as Unicode letters, and those in category Nd as Unicode digits.

    The 'short' answer is that some operators are supported, depending on their character class. The more esoteric/specialist ones won't be.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私