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?

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.)

It's Go's special internal syntax for Go package paths. For example,

runtime∕pprof·runtime_cyclesPerSecond

is function runtime_cyclesPerSecond in package path runtime∕pprof.

The '' character is the Unicode division slash character, which separates path elements. The '·' character is the Unicode middle dot character, which separates the package path and the function.