Hello,
> My understanding is the `zero` variable just provides a unique memory location, and any type, e.g. byte, would have worked just as well. Is this right?
Yes.
> Was uintptr choosen for performance reasons? Or to guarantee alignment?
None of the above.
`uintptr` was chosen for being consistent with runtime.zerobase, which is also an uintptr.
Before `runtime.zerobase` is used, it was `runtime.zeroObject`, which is a `byte`, that's the result of rewriting mallocgc from C -> Go.
In the mallocgc C source, the zerobase is defined as an uintptr:
extern uintptr runtime·zerobase;
Then in the process of support for auto-generating Go constants from the C definitions, duplicated constants were removed, prevent
out of sync between C and Go constants. The result is that zeroObject was removed and `runtime·zerobase` becomes `runtime.zerobase`.
Last but not least, since unique.zero and rutime.zerobase represents the base memory address of 0-byte object, what's better than an uintptr?
My 2 cents.