|
|
|
|
|
by beautron
880 days ago
|
|
Yes, I'm saying Go's slice operator (and slice type, and related functions) grew out of experience from the way arrays are used in C. To me, this becomes obvious if you read The Practice of Programming by Kernighan and Pike, the latter of which was a co-designer of Go. If you read the book, which was written well before Go, and pay attention to how it uses C arrays, you can almost feel Go slices emerging. The slice syntax perfectly encapsulates the C array bookkeeping. |
|
In comparison, your claim only makes sense when the following was somehow normal:
Note that a hypothetical `subslice` function call maps perfectly to a Go code `out[0:len(out)-1]`, and my complaint will equally apply: there should be two clearly named variants of `subslice` that may or may not keep the capacity. But I hardly saw such construction in C.