On Mon, Feb 20, 2017 at 9:12 AM, T L <tapir....@gmail.com> wrote: > > I know gc assures this, but I don't know if it is compiler specified or a > spec rule.
I can't think of any way that a Go program that does not unsafe could detect whether a string slice uses the same memory as the string being sliced. Also, I can easily imagine that in some cases it would be desirable to make a copy, as when writing s[i:i+1] when len(s) > 4096 and there are no other references to s. So I don't think this should be written down in the spec. I think Go programs should trust that the implementation will make the right choice, which will of course be to normally not copy the string. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.