When implementing the interpreter for my programming language I first thought of a simple console window which allows the user to enter some code which is then executed as a standalone program as a shell.
But there are severe problems: If every line of code the user enters is handled as a standalone program, it has to go through the tokenizer and parser and is then just executed by the interpreter - what about functions then?
- How can the Python/Ruby interactive consoles (IDLE, irb) "share" the code? How is the code entered handled?
Example:
>> def x:
>> print("Blah")
>>
>> x()
Where is the function stored so it can be called at any time again?
How can the interactive console take everything entered as obviously one program without executing everything over and over again?