Using the REPL

The Improvise REPL (Read Eval Print Loop) improves on the standard eval command found in most legacy cores.  It supports multi-line command building, remembers past variable assignments, and integrates with other commands, like @inspect.  Users of similar tools in other languages will find the means of interaction familiar.

Just like the eval command in legacy cores, expressions are immediately evaluated:

; 3 + 5

This is equivalent to the statement:

; return 3 + 5;

If a statement as entered is incomplete, but additional lines could make it complete, the REPL allows the programmer to continue to enter lines until a syntactically complete statement is formed.  The REPL will then evaluate that statement and return the result (if any).  Typing a single period (.) on a line by itself aborts the editing process.

; for o in [#0..#3]
Enter lines of code. Enter a single period (".") to abort editing.
System Server Options Kernel Package Kernel Dictionary

If the starting fragment, or any subsequent line, is incomplete but not correctable, the REPL will simply return one or more syntax errors.

; for [1..5]
Line 1: Expected `in'

The REPL also remembers past variable assignments.  These values are automatically available in future evaluations.

; for i in [1..5]
Enter lines of code.  Enter a single period (".") to abort editing.
  tot = (tot !! E_VARNF => 0) + i
  {last, j, @foo} = {tot, i}
  /* x = "not fooled by comments" */
; i
; tot
; last
; j
; x
#-1:Input to EVAL (this == #-1), line 19:  Variable not found
... called from built-in function eval()
... called from #21236:eval*uate, line 115
(End of traceback)

The REPL remembered the last values of i, j, tot, and last, but was not fooled by an assignment in a comment (we're not using simple regular expressions).

; tot += last
; tot

Other commands, like @inspect, have access to these variables, when appropriate.

; x = player
#50 "Wizard"
@inspect x
"Wizard" (#50) -rwfa player, programmer, wizard Parents: {#21238, #21233, #76}, Children: {} Location: #51, Contents: {} Owner: #50 -- Verbs -- map [dirty] application/x-moocode {#50, "xd", "map"} {"any", "any", "any"} blitz {#50, "d", "blitz"}

More usefully, this works with anonymous objects, too.

; x = create($object, 1)
*anonymous* ""
@ins x "" (*anonymous*) -rwfa
Parents: {#4}, Children: {} Location: #-1, Contents: {} Owner: #50 -- Properties from "Object" (#4) -- aliases [clear] {} {#50, "c"} (done)


Todd Sundsted