Skip to content
This repository has been archived by the owner on Aug 5, 2023. It is now read-only.

Interpreter freeze in infinite while loop #1

Open
sahilverma0696 opened this issue May 15, 2020 · 3 comments
Open

Interpreter freeze in infinite while loop #1

sahilverma0696 opened this issue May 15, 2020 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@sahilverma0696
Copy link

let number x be 1
loop while x  <2:
    display 'Hello'

The webpage crashed!!

@vighnesh153
Copy link
Owner

vighnesh153 commented May 15, 2020

That is a mistake that I did a lot of times too. You are not updating x. So, it is always 1 and hence, an infinite loop. In this iteration, I am just letting it go. There is no detection mechanism for an infinite loop.

@sahilverma0696
Copy link
Author

That is a mistake that I did a lot of times too. You are not updating x. So, it is always 1 and hence, an infinite loop.

let number x be 1
loop while x  <2:
    display 'Hello'

The webpage crashed!!

Atleast the editor shoudn't.

@vighnesh153 vighnesh153 reopened this May 15, 2020
@vighnesh153 vighnesh153 added the enhancement New feature or request label May 15, 2020
@vighnesh153 vighnesh153 added the help wanted Extra attention is needed label May 23, 2020
@vighnesh153
Copy link
Owner

vighnesh153 commented May 23, 2020

Now that I think about it, it seems that it is very difficult to detect an infinite loop. If the user is printing something, the buffer may get filled with a lot of data and that would hint that something is wrong in the code. But this would only be the best case. What if user doesn't print anything? Well, then we will never know if the code has an infinite loop. A possible solution would be after every iteration in a while loop, we check any of the variables in the scope have changed their values but then it will become very inefficient and also, what if the user changed some value which is not affecting the expression check of the loop? There are a lot many possibilities and cases that would need to be handled and I don't think that is humanely possible to do that.

Anyway, if you got any idea, I am all ears.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants