bril icon indicating copy to clipboard operation
bril copied to clipboard

[Typescript Compiler] Add for loops to typescript compiler

Open atucker opened this issue 3 years ago • 1 comments
trafficstars

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.

atucker avatar Feb 08 '22 22:02 atucker

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.

sampsyo avatar Feb 08 '22 23:02 sampsyo