Skip to content

spec: document range-over-func #65237

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
rsc opened this issue Jan 23, 2024 · 7 comments
Closed

spec: document range-over-func #65237

rsc opened this issue Jan 23, 2024 · 7 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Documentation Issues describing a change to documentation. NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@rsc
Copy link
Contributor

rsc commented Jan 23, 2024

Tracking bug for adding range-over-func to spec. See #61405.

@rsc rsc added the NeedsFix The path to resolution is known, but the work has not been done. label Jan 23, 2024
@rsc rsc added this to the Go1.23 milestone Jan 23, 2024
@gopherbot gopherbot added the Documentation Issues describing a change to documentation. label Jan 23, 2024
@cherrymui cherrymui added the compiler/runtime Issues related to the Go compiler and/or runtime. label Mar 13, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/589397 mentions this issue: spec: document for range loop over functions

@3052
Copy link

3052 commented Jun 4, 2024

@griesemer this example is not great

// print hello world
f := func(yield func(string) bool) {
	if yield("hello") {
		yield("world")
	}
}
for word := range f {
	println(word)
}

its not clear when yield would return true or false, looking at the example alone

@griesemer
Copy link
Contributor

@3052 Agreed. And there's a TODO (html comment) in the spec to fix it. One step at a time.

@3052
Copy link

3052 commented Jun 4, 2024

one of the reasons I love Go is that it is very "readable", but the above example is not that at all. I will be patient and wait on updates to the example, but I have strong concerns about the impact of this new change on how easy it is to read Go code.

@Malix-Labs
Copy link

@griesemer #65237 (comment)

there's a TODO (html comment) in the spec to fix it

Is there an opened issue about it ?

@griesemer
Copy link
Contributor

Change is in the works.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/590396 mentions this issue: spec: better examples for range-over-func

gopherbot pushed a commit that referenced this issue Jun 4, 2024
For #65237.

Change-Id: Id38747efebd46633f453eadaf68d818064faa778
Reviewed-on: https://go-review.googlesource.com/c/go/+/590396
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Documentation Issues describing a change to documentation. NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
Status: Done
Development

No branches or pull requests

7 participants