by kortex · 6y ago · 0 comments
type slice struct {
zerothElement *type
len int
cap int
}
Though I suspect under the hood the len and cap are ordered first.If it's good enough for C greybeard Ken Thompson and unix hacker Rob Pike, its good enough for me.
In fact I've looked for a port of go-style slices to C and haven't found one. Maybe people think sds is good enough?
A slice is stored in memory as a `reflect.SliceHeader` https://golang.org/pkg/reflect/#SliceHeader ; the pointer does come first.
https://github.com/jgbaldwinbrown/slice
It's just a proof-of-concept, though, and would need a lot of work to be used in anything serious.