Go lets you return an interior reference. But Go uses a garbage collector instead of lifetime checks at compile time (which is an advantage or a drawback, depending on your requirements).
Go lets you return an interior reference. But Go uses a garbage collector instead of lifetime checks at compile time (which is an advantage or a drawback, depending on your requirements).
But the key point stands wrt Go; Go is among the languages that "can't do this." First, there is no way to get a reference to a field inside a struct in Go (the workaround is reflection which has runtime overhead, and therefore doesn't count) and if you could get such a reference the compiler would be forced to reference count the member via the GC to satisfy the Go memory model.
what?
https://play.golang.org/p/1OJ5U5ZwFJ
> if you could get such a reference the compiler would be forced to reference count the member via the GC to satisfy the Go memory model
no reference counting in go.