Open afroozeh opened 2 years ago
This makes total sense. Toplevel behavior should be different in the REPL. The same holds for functions. Sometimes you just want to replace a function definition with a new version rather than adding a new (non-deterministic) alternative.
the implicit variable name feature is also cool. maybe we could solve this by binding it
with the latest result, just like $?
in bash?
I think in other REPLs the implicit variable names all stay in the scope when the REPL session is valid, so they should go to the top-level environment. As far as I know, $?
will refer to the last executed one, so it will be rewritten. Maybe you can just bind it
to an implicit auto-incremented name that is put in the env?
Also would be good to drop semicolon requirement for statements as well. It's particularly noticeable when importing modules. This screenshot is from the Java REPL (JShell in Java 11).
agreed; we locked the grammar while working on the compiler, but this is a possible and useful feature.
I've been working a bit with the Rascal REPL in the last weeks, and compared to Scala/Node.JS REPLs, I miss two features:
Redefining values: Rascal throws an error that the variable is already declared. I can imagine that because of immutability this is desired in the language, but for REPL, I'd consider it a bit of restriction. Especially when experimenting, it's hard to restart the REPL or choose a different variable name each time.
Giving names to expressions that are not assigned. Another handy feature that I miss is giving a temporary name to expressions. This is also useful for experimentation.