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 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化