My salution to Nim communtiy.
I was very shocked when I saw a Nim REPL (aka Interactive mode) in rosetacode when I was exploring things, find it here http://rosettacode.org/wiki/Interactive_programming#Nim
I have not seen anything about REPL in the documentations. Unfortunatley, my desktop is at the maintenance now, but I am very excited to use it if it is stable and real!
That functionality is no longer valid.
There are some quasi REPL offerings in nimble (compile and run in the background?)
Krux02, that is exactly right. As we know, Nim is a fully compiled language (but also supports some runtime features), I haven't seen any REPL for any compiled languages.
It is the"eval" part that needs runtime and/or an interpreter, this is a basic REPL in Lisp: (loop ( print ( eval ( read ))))
Why not write Nim compiler like this? Cross-compiler written as a library over an interpreter. The coding style will change, but it will have much more power.
We write some script code, which does low stuff, build models as data structures, for example, classical AST but not limited. Then, run compiler() function with this source model.
Next, the compiler does its work, update symbol table, check types, etc bla bla bla
Compiler iteration stops, we got control and run the next part of a script. Now we can dive into the compiler's data structures, check something manually, get some data from an external database or network service, build the next source model, and run compiler stage again.
Finally, at the end of file or direct compiler.commit() call, he flushes all binary buffers into object files, stops the interpreter, and exits to OS.
Also a bit annoying that variables can't be redefined
I suppose adding this should not be too hard, but I don't know the details of inim very well. All I know is that it essentially keeps the REPL input as a temporary file that gets recompiled. If one were to map let and var statements from the REPL input to some Table[string, string] (variable name ⇒ value) one could track if a variable is being redefined and overwrite the value in the table. The generation of the temp file would just need to be based on essentially a table serialization.
The being faster part, yeah. One should be able to use it with tinyC though, which should help somewhat.