News for hackers. Stuff that matters.
Re:Fixing for Loops in Go 1.22 by sixstringtheory on Tuesday September 19, 2023 @05:07PM (#37576677)
Doesn't that mean that all code written so far can't take up newer versions of the Go compiler for any other reason like new features/bugfixes/optimizations/etc without a full audit of codepaths involving for loops?
Re:Fixing for Loops in Go 1.22 by ericpauley on Tuesday September 19, 2023 @05:47PM (#37577282)
No, it does not. Packages can compile using 1.22 and gain other benefits without opting into this change.
Re:Fixing for Loops in Go 1.22 by sixstringtheory on Tuesday September 19, 2023 @06:54PM (#37578191)
Ah, I didn't see the part about //go:build
Re:Fixing for Loops in Go 1.22 by acheong08 on Wednesday September 20, 2023 @02:17AM (#37580953)
Without /:go:build tags, you can just define 1.21 as your Go version in go.mod to opt out of new features while getting other benefits of the new compiler
Re:Fixing for Loops in Go 1.22 by kevincox on Tuesday September 19, 2023 @08:52PM (#37579129)
No, the version declared in go.mod is different than the version of the toolchain used to compile the project. If you declare an older version even new toolchains will act like the previous versions.
Re:Fixing for Loops in Go 1.22 by s17n on Wednesday September 20, 2023 @02:53AM (#37581186)
There isn’t really anything that you could actually use the old behavior for, any code that depends on it is probably wrong anyway.
Re:Fixing for Loops in Go 1.22 by Cthulhu_ on Wednesday September 20, 2023 @04:00AM (#37581639)
No I don't think so; any old working code will be using the x := x workaround, which will keep working when going to this version with the changed loop mechanics. What may happen is a form of... some adage, I forgot the name, where code accidentally relies on the old behaviour and breaks when that old behaviour is no longer there.

(that same adage applies to e.g. browser manufacturers having to implement bugs to not break certain websites)

Re:Fixing for Loops in Go 1.22 by Quekid5 on Wednesday September 20, 2023 @07:04AM (#37582714)
Are you thinking of Hyrum's Law?
Re:Fixing for Loops in Go 1.22 by sgerenser on Wednesday September 20, 2023 @10:10PM (#37592493)
Whatever, just give me an option to enable spacebar heating. https://xkcd.com/1172/
Re:Fixing for Loops in Go 1.22 by Quekid5 on Sunday September 24, 2023 @05:34PM (#37637424)
I enjoyed that reference :)