On Tue, 2020-05-26 at 16:26 +1000, Jesse McNelis wrote:
> On Tue, May 26, 2020 at 3:37 PM Paul Jolly <p...@myitcv.io> wrote:
> > > Why the output of this code is nondeterministic?
> > 
> > See https://golang.org/ref/spec#For_statements, specifically the
> > "For
> > statements with range clause" subheading, specifically this bullet:
> > 
> > > 3. The iteration order over maps is not specified and is not
> > guaranteed to be the same from one iteration to the next. If a map
> > entry that has not yet been reached is removed during iteration,
> > the corresponding iteration value will not be produced. If a map
> > entry is created during iteration, that entry may be produced
> > during the iteration or may be skipped. The choice may vary for
> > each entry created and from one iteration to the next. If the map
> > is nil, the number of iterations is 0.
> 
> The implementation actually intentionally makes the iteration order
> more varied to avoid people relying on any particular ordering. So
> much so that some people started relying on the order to be
> random....
> 

Also to prevent algorithmic complexity attacks like this 
http://ocert.org/advisories/ocert-2011-003.html


-- 
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/8f413dc6a93c6ab50c1c6be9da00668400fde6a1.camel%40kortschak.io.

Reply via email to