Juan Reynoso Elias
En 2017-06-23 14:04:52
Read Eval Print Loop (REPL)
 

You interective with y
our Lisp system through a build-in  piece of code called the toploop, which repeats three simple steps for as long as you run the Lisp system.

  1. Read an expresion.
  2. Evalue the expresion just read.
  3. Print the result of the evaluation. 

Let's do it

 (defun my-toploop ()
  (loop
     (terpri); print a new line
      (princ 'ready>) ;print phase

     ;; displays the result of the evaluation
      (print (eval (read)))))
 


And some functions to call 

(defun hello ()
  (format t "Hello!"))

(defun test (x)
  (+ x 10))

Try it!

CL-USER> (my-toploop)

READY>

READY> (+ 5 5)

10 

READY> (hello)
Hello!
NIL
READY>(test 5)

15
READY>


Getting out of you toploop

enter an erroneus expression like ( + 2 'a)