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

Consider unrolling loop sytax in CashScript #240

Open
mr-zwets opened this issue Nov 8, 2024 · 0 comments
Open

Consider unrolling loop sytax in CashScript #240

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

Comments

@mr-zwets
Copy link
Member

mr-zwets commented Nov 8, 2024

Now that Bitcoin Cash is going to get increased VM limits, it becomes more plausible developers will want to use 'unrolled loops'. This would just be code repeated x times where x is known at compile time and cannot be a variable. The looping construct will only be able to take a number argument, not a variable.

If we were to enable it, the syntax should make clear to the developer that this loop will be unrolled in size and so any if branching logic will take up a huge amount of space. Either the keyword unroll or unroll for would make this very clear.

unroll(256) {
  // Code to be unrolled and repeated 256 times
}

If people want to have a counter variable they would need to create this explicitly

int i = 0; // Initialize a counter variable

unroll(256) {
  // Increment the counter explicitly
  i = i + 1;
}
@mr-zwets mr-zwets added the cashc-compiler Relates to the cashc compiler label Nov 8, 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