Skip to content
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

Potential syntax for bounded loops (2026 proposal) #246

Open
mr-zwets opened this issue Dec 13, 2024 · 0 comments
Open

Potential syntax for bounded loops (2026 proposal) #246

mr-zwets opened this issue Dec 13, 2024 · 0 comments
Labels
cashc-compiler Relates to the cashc compiler

Comments

@mr-zwets
Copy link
Member

There is a bounded loops proposal for BCH.

It would be good to consider the possible syntax this would translate to in CashScript.
The bounded loops construction enables indefinite loops, which can easily emulate definite loops.

From the spec:

Naming and Semantics

This proposal is influenced by the BEGIN ... UNTIL indefinite loop construction in the Forth programming language (upon which the rest of the Bitcoin Cash VM is based). This particular construction offers maximal flexibility: definite loops can be easily emulated with indefinite loops, but indefinite loops cannot be emulated with definite loops.

So there would both be a for and a while loop syntax.
I got the solidity syntax for both, I think they're the same a Javascript:

while (i != 0) {
    // do something
}
for (uint i = 1; i <= 5; i++) {
    // do something
}
@mr-zwets mr-zwets added the cashc-compiler Relates to the cashc compiler label Dec 13, 2024
@mr-zwets mr-zwets changed the title Potenential syntax for bounded loops (2026 proposal) Potential syntax for bounded loops (2026 proposal) Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cashc-compiler Relates to the cashc compiler
Projects
None yet
Development

No branches or pull requests

1 participant