From 344075d9369103a453add5acf3cb6d68057e8423 Mon Sep 17 00:00:00 2001
From: Olivier Mengué
Date: Wed, 1 May 2024 23:18:00 +0200
Subject: 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
---
doc/go_spec.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'doc')
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.
--
cgit v1.2.3-54-g00ecf