-
Notifications
You must be signed in to change notification settings - Fork 23
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
Variables don't persist #130
Comments
I don't quite understand the bug here, but you must remember that unlike python, there's no 'runtime' for variables to persist in. Can you explain more? |
The example is counter intuitive, since Instead, |
Agreed. It is counter-intuitive. However, I believe what @0atman is saying is, whenever you type a line of code, that line is added to a source file somewhere and the source file is recompiled and executed. So every time you enter a line of code, it is literally as if you just entered all the lines, right then, in one operation. Therefore, of course the value of |
Of course, this means the longer you continue at the REPL, the slower and slower compilation will become. Doesn't strike me as a particularly viable solution, to be honest. |
What we must remember is that there's NO compiler execution happening apart from the read loop between lines. inim-repl is a best effort, given the constraints of the nim language. Any language that has no persistent runtime for variables to hang around in would behave the same. Should we fake it to be similar to python? I'm not sure. That could cause some edge cases for people who assume nim will behave like nim. I'd be interested to hear thoughts on the matter 😃 |
Depends. Fake it how, exactly? Is my assumption correct? As in, the REPL currently works like this:
In which case, how do you avoid printing output from previous lines? Why didn't the second
|
Do you perhaps modify the previous lines to be unable to produce output? Like, set STDOUT to null or something until the last line is reached, then set it back? |
I think having a REPL that re-runs all previous commands every time you type something is a Bad Idea™. Suppose there are important commands higher up? Like file deletions or non-idempotent actions? I think it might make more sense to let the user enter multiple lines, then type And also have a |
how to reproduce the bug
First, have a file named
test.nim
:Then: do this in inim
The text was updated successfully, but these errors were encountered: