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

Should console.log yield control? #102

Open
arjunguha opened this issue Jul 9, 2019 · 0 comments
Open

Should console.log yield control? #102

arjunguha opened this issue Jul 9, 2019 · 0 comments

Comments

@arjunguha
Copy link
Member

Today I tried to run effectively this program:

let exit = false;
while (!exit) {
  if ('redbull64' === prompt('Enter password')) {
    exit = true;
  }
  else {
    console.log('Wrong password');
  }
}

If the user keeps entering the wrong password, this program does not reliably display "wrong password" on each iteration. The problem is that console.log involves DOM updates that only display when the turn ends. Neither console.log nor prompt end the turn, so the turn only ends when Stopify suspends the loop, which is nondeterministic.

So, we need either console.log or prompt to suspend and immediately resume execution. I propose we modify console.log, so that it always prints immediately. This will significantly slow down programs that display in a loop, but it will make them more responsive.

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

No branches or pull requests

2 participants