Let me please ask for clarification about code like this:package main
type t struct {
// ...
}
func (p *t) foo() {
// ...
}
func bar() []t {
return nil // but actually some non-empty slice of t
}
func main() {
for _, v := range bar() {
v.foo() // <-- line 17
}
}1) Currently line 17 allocates at most a single instance of t for all loop passes, with the proposal it may allocate one instance of t for every loop pass.
2) With the proposal, code snippets published anywhere, both existing and the future ones, online or printed, cannot be read and analysed correctly by a human if the go directive used in go.mod, or the go.mod per se is not available to the reader. Even if the go.mod is available, like when working within a repository, it defines the semantics of the for loop, but in a different file. In contrast to, for example, build tags, located conveniently near the top of the same file or implicitly in the [same] file name.
2) With the proposal, code snippets published anywhere, both existing and the future ones, online or printed, cannot be read and analysed correctly by a human if the go directive used in go.mod, or the go.mod per se is not available to the reader. Even if the go.mod is available, like when working within a repository, it defines the semantics of the for loop, but in a different file. In contrast to, for example, build tags, located conveniently near the top of the same file or implicitly in the [same] file name.
--
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-dev/CACKEwjF3_Xv1bAw4KVmrVWZg06kYQimmutV6T8NPQgPq6pZRdQ%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-dev/a6e721a5-402e-4303-84fd-b68c19331958n%40googlegroups.com.
I wonder if we could use a conditional compilation comment and provide per package migration support?