Skip to content

Comment on Strings, bytes, runes and characters in Goparent

Comments

I did run into at least one eminently reasonable use of how Go source is defined to be in UTF-8. Comments in the crypto libs just use math symbols where they're handy, like this in crypto/rsa[1]:

  // Check that de ≡ 1 mod p-1, for each prime.
  // This implies that e is coprime to each p-1 as e has a multiplicative
  // inverse. Therefore e is coprime to lcm(p-1,q-1,r-1,...) =
  // exponent(ℤ/nℤ). It also implies that a^de ≡ a mod p as a^(p-1) ≡ 1
  // mod p. Thus a^de ≡ a mod n for all a coprime to n, as required.
Sadly, the spec requires identifiers to be just Unicode letters and digits, so we will never experience the power and glory of emoji function names in Go.

[1] http://golang.org/src/pkg/crypto/rsa/rsa.go

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.