On Sat, Mar 25, 2023 at 2:33 AM Amnon <amno...@gmail.com> wrote:

> Thanks for a very succinct response.
>
> So if I understand the CL, there will be no change in behaviour in 1.21,
> unless you set GOEXPERIMENT=loopvar
>
> - Amnon
>

That's correct. You (and everyone else) can play with this GOEXPERIMENT in
1.21 (or now, if using gotip). The most useful thing to do would be to run
your tests with this experiment set and see what breaks.

Looking towards the future, this is also related to the forward
compatibility proposal: https://github.com/golang/go/issues/57001

Eli





>
>
>
> On Saturday, 25 March 2023 at 06:56:23 UTC Sean Liao wrote:
>
>> https://go.dev/issue/57969
>>
>> - sean
>>
>> On Sat, Mar 25, 2023, 06:45 Amnon <amn...@gmail.com> wrote:
>>
>>> Hi Gophers,
>>> Last year there was a discussion about removing one of the
>>> more common gotchas in Go.
>>>
>>> To quote from the discussion:
>>>
>>> the problem is that loops like this one don’t do what they look like
>>> they do:
>>>
>>> var all []*Item
>>> for _, item := range items { all = append(all, &item) }
>>>
>>> That is, this code has a bug. After this loop executes, all contains
>>> len(items) identical pointers, each pointing at the same Item, holding
>>> the last value iterated over. This happens because the item variable is
>>> per-loop, not per-iteration: &item is the same on every iteration, and
>>> item is overwritten on each iteration.
>>> https://github.com/golang/go/discussions/56010
>>>
>>> What was the resolution of this discussion?
>>> Was the proposed change accepted?
>>> Will it be released in Go 1.21 or 1.22?
>>>
>>> It is hard to figure this out from the discussion. There are hundreds of
>>> comments,
>>> but there is no clear marking of the resolution (apart from the
>>> discussion now being closed) either at the top of bottom of the discussion.
>>>
>>>
>>> --
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/golang-nuts/5d88208e-fbbf-44d5-b693-50deff176fedn%40googlegroups.com
>>> <https://groups.google.com/d/msgid/golang-nuts/5d88208e-fbbf-44d5-b693-50deff176fedn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/aba5e0bd-c676-45f0-a7b7-ce6e23985124n%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/aba5e0bd-c676-45f0-a7b7-ce6e23985124n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAF-Rda8Mj4NQKY-gCLudGMKowAkUVbFFnWRBqCVbV8%2BpKpdORw%40mail.gmail.com.

Reply via email to