douao3063 2013-04-28 02:54
浏览 19
已采纳

Go编译器运行时的语法和语义

I was looking at the runtime.c file in the go runtime at

  /usr/local/go/src/pkg/runtime

and saw the following function definitions:

   void
   runtime∕pprof·runtime_cyclesPerSecond(int64 res)
   {...}

and

int64
runtime·tickspersecond(void)
{...}

and there are a lot of declarations like

void    runtime·hashinit(void);

in the runtime.h.

I haven't seen this C syntax before (specially the one with the slash seems odd). Is this part of std C or some plan9 dialect?

  • 写回答

2条回答 默认 最新

  • dongnanbi4942 2013-04-28 03:10
    关注

    and · and friends are merely random Unicode characters that someone decided to put in function names. Obscure Unicode characters (edit: that are listed in Annex D of the C99 standard (pages 452-453 of this PDF); see also here) are just as legal in C identifiers as A or 7 (in your average Unicode-capable compiler, anyway).

    Char|   Hex| Octal|Decimal|Windows Alt-code
    ----+------+------+-------+----------------
    ∕   |0x2215|021025|   8725|          (null)
    ·   |  0xB7|  0267|    183|        Alt+0183
    

    Putting characters that look like operators but aren't (U+2215 , in particular, resembles U+2F / (division) far too closely) in function names can be a confusing practice, so I would personally advise against it. Obviously someone on the Go team decided that whatever reasons they had for including them in function names outweighed the potential for confusion.

    (Edit: It should be noted that U+2215 isn't expressly permitted by Annex D. As discussed here, this may be an extension.)

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

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭