Skip to content

proposal: add do...for loop #70064

New issue

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

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

Already on GitHub? Sign in to your account

Closed
4 tasks
lorypelli opened this issue Oct 26, 2024 · 6 comments
Closed
4 tasks

proposal: add do...for loop #70064

lorypelli opened this issue Oct 26, 2024 · 6 comments
Labels
LanguageChange Suggested changes to the Go language LanguageChangeReview Discussed by language change review committee Proposal
Milestone

Comments

@lorypelli
Copy link

lorypelli commented Oct 26, 2024

Go Programming Experience

Intermediate

Other Languages Experience

JS, TS, Python, C, Java, Kotlin

Related Idea

  • Has this idea, or one like it, been proposed before?
  • Does this affect error handling?
  • Is this about generics?
  • Is this change backward compatible? Breaking the Go 1 compatibility guarantee is a large cost and requires a large benefit

Has this idea, or one like it, been proposed before?

No, it would be good to make a loop executed at least one time without duplicating code...

Does this affect error handling?

No

Is this about generics?

No

Proposal

sintax like this maybe:
i := 0
do {
i++
println(i)
} for (i < 5)

Language Spec Changes

No response

Informal Change

No response

Is this change backward compatible?

There is an entire new keyword and loop body is in a different place, I don't think so...

Orthogonality: How does this change interact or overlap with existing features?

No response

Would this change make Go easier or harder to learn, and why?

No response

Cost Description

No response

Changes to Go ToolChain

No response

Performance Costs

No response

Prototype

No response

@lorypelli lorypelli added LanguageChange Suggested changes to the Go language LanguageChangeReview Discussed by language change review committee Proposal labels Oct 26, 2024
@gopherbot gopherbot added this to the Proposal milestone Oct 26, 2024
@seankhliao
Copy link
Member

Duplicate of #55868

@seankhliao seankhliao marked this as a duplicate of #55868 Oct 26, 2024
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Oct 26, 2024
@lorypelli
Copy link
Author

Duplicate of #55868

that issue was closed and I don't like using break keyword

@lorypelli
Copy link
Author

and that would also be an infinite loop which is not that cool

@seankhliao seankhliao marked this as not a duplicate of #55868 Oct 26, 2024
@seankhliao
Copy link
Member

Duplicate of #34896

@seankhliao seankhliao marked this as a duplicate of #34896 Oct 26, 2024
@seankhliao
Copy link
Member

in either case adding more syntax sugar isn't really the solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LanguageChange Suggested changes to the Go language LanguageChangeReview Discussed by language change review committee Proposal
Projects
None yet
Development

No branches or pull requests

4 participants