Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Indefinite loop that breaks Codea.

AnatolyAnatoly Mod
in Bugs Posts: 889
    for a in function()
        return 2
    end do

Codea gets stuck after activation.



  • Posts: 1,749

    @Anatoly - yup, same on my machine but I can't really understand what you are trying to achieve with that code?

  • dave1707dave1707 Mod
    edited November 2019 Posts: 8,453

    Just about any infinite loop will crash Codea. The one below will crash too.

    One thing I noticed when I was playing with this, any code changes weren’t saved. But that was expected because I know that if Codea crashes, it doesn’t save code changes.

    @Simeon One thing I noticed running @Anatoly code above, even if I did the Save and Run, the code wasn’t saved. It reverted back to the original code.

    PS. Even my code wasn’t saved when I did the Save and Run. I wonder if any kind of a problem in setup might be causing the loss of code.

    function setup()
        while true do
  • That's an interesting infinite loop. The anonymous function is defining an iterator which can be repeatedly called. The classic iterator is ipairs, but it's possible to define your own. In this code, you're defining an iterator which returns the value 2 whenever it is called.

    The for ... in ... syntax will keep calling the iterator until it gets a nil. Since it always returns 2, it will never end and the for loop will keep going round.

    As I said - an interesting infinite loop!

  • AnatolyAnatoly Mod
    edited November 2019 Posts: 889

    @dave1707 nice to notice that if you remove the print function,you can still exit the code. It’s hard, but possible.

    I believe it’s because printing is such a slow function. Not sure however why Save & Run won’t work.

    @LoopSpace was trying to create my own interators, just was testing out some stuff.

    It’s suggested for anyone who uses the while loop:
    - Before the indefinite loop create n which equals zero.
    - Inside the loop (1) increase n by one and
    - (2) check if n is more than 10000 (or less), after which break the loop.

  • AnatolyAnatoly Mod
    Posts: 889

    Sadly my internet lagged out and the post was trashed. Here were two points:

    • Recording is Brocken
    • Opening alerts in a for loop is bad. (Earlier you could escape it)
  • AnatolyAnatoly Mod
    Posts: 889


    One thing I noticed running @Anatoly code above, even if I did the Save and Run, the code wasn’t saved. It reverted back to the original code.

    Today happened again.

    Summary: First of all, the editor dies. The comments stop being green, an error is shown even if already fixed. Exiting the app let’s to code loss. I believe this is a bug with the error message (which checks the code while being coded for syntax). Probably at some point it stops checking and ignores code changes. (Since your code is stored in two different ways: A string variable of what you see right now and the storage where your code is saved. I believe specific errors lose the connection.

Sign In or Register to comment.