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

We need a run-immediately-friendly loop construct #62

Open
dbarowy opened this issue Jan 11, 2019 · 2 comments
Open

We need a run-immediately-friendly loop construct #62

dbarowy opened this issue Jan 11, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@dbarowy
Copy link
Contributor

dbarowy commented Jan 11, 2019

Right now, we do not ask students to do anything with loops because they interact poorly with the fact that our editor evaluates the program as soon as the code parses. This is problematic, because you could be in the middle of writing out something like:

for()

which will run forever, promptly locking up the UI.

@dhmquan and I briefly discussed a repeat construct that would not have this same issue. E.g.,

repeat(5) {
  // whatever
}

One downside is that this construct does not provide a lexically-scoped loop variable like for. However, I think that this is OK. First, this is a learning tool, not a production language. Second, one can easily introduce a loop variable with:

i = 0;
repeat(5) {
  // do something with i
  i += 1;
}
@dbarowy dbarowy added the enhancement New feature or request label Jan 11, 2019
@dbarowy
Copy link
Contributor Author

dbarowy commented Jan 11, 2019

It should be added that repeat() would not be a valid program.

@dhmquan
Copy link
Collaborator

dhmquan commented Jan 11, 2019

Can support this construct, but scope is incorrect:

i = 1;
repeat(3) {
 i = i + 1;
}
print(i, 140, 123);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants