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

[Typescript Compiler] Add for loops to typescript compiler #174

Open
atucker opened this issue Feb 8, 2022 · 1 comment
Open

[Typescript Compiler] Add for loops to typescript compiler #174

atucker opened this issue Feb 8, 2022 · 1 comment

Comments

@atucker
Copy link
Contributor

atucker commented Feb 8, 2022

The typescript compiler doesn't seem to handle for loops right now.

It seems like one way to handle it would be to:

  1. Make a new loop name
  2. Set up the iterator variable assignment once
  3. Set up the iterator variable increment in the body of the loop
  4. Set up the end condition computation, and jump back after

One issue I guess with adding for loops is that it's not super obvious which loops users should expect to work or not, and so it might create a lot of implied work (to handle other loops), but maybe a decent way of handling it would just be to see if the user seems to be using some type of loop, and have the error message explain which type of loop they can do.

@sampsyo
Copy link
Owner

sampsyo commented Feb 8, 2022

Yeah! Maybe just supporting plain old "classic" for loops would be a good start. You know, the kind with for (var i = 0; i < lst.length; ++i). That seems pretty easy to compile tbh, unlike modern "foreach" loops.

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

No branches or pull requests

2 participants