From: Olivier Mengué
Date: Wed, 1 May 2024 21:18:00 +0000 (+0200)
Subject: spec: clarify when range expression is evaluated
X-Git-Tag: go1.23rc1~483
X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=344075d9369103a453add5acf3cb6d68057e8423;p=gostls13.git
spec: clarify when range expression is evaluated
Clarify that the range expression of a "for" loop is called *just* once to
rule out that it might be re-evaluated after each iteration.
Change-Id: Iedb61cd29e5238ac0168b8ac01c34d6208cc4312
Reviewed-on: https://go-review.googlesource.com/c/go/+/582775
Reviewed-by: Robert Griesemer
Auto-Submit: Ian Lance Taylor
LUCI-TryBot-Result: Go LUCI
Reviewed-by: Ian Lance Taylor
---
diff --git a/doc/go_spec.html b/doc/go_spec.html
index ac27c1d6c1..277cd27775 100644
--- a/doc/go_spec.html
+++ b/doc/go_spec.html
@@ -6643,7 +6643,7 @@ the range clause is equivalent to the same clause without that identifier.
-The range expression x
is evaluated once before beginning the loop,
+The range expression x
is evaluated before beginning the loop,
with one exception: if at most one iteration variable is present and x
or
len(x)
is constant,
the range expression is not evaluated.