1. 10
  1. 3

    The one key thing this blog post is missing: “but why?”

    1. 3

      Following one of the article’s links leads to Go issue 395 which contains the following motivation statement:

      One motivation for doing this is that using an array pointer allows the compiler to range check constant indices at compile time.

      a function like this:

      func foo(a []int) int { return a[0] + a[1] + a[2] + a[3]; }

      could be turned into:

      func foo(a []int) int { b := a.[0:4]; return b[0] + b[1] + b[2] + b[3]; }

      allowing the compiler to check all the bounds once only and give compile-time errors about out of range indices.