Function: INTERACTIVE-INTERPRETER

Documentation

simple configurable REPL

Source

(defun interactive-interpreter (&key (prompt "#> ")
				(print #'print)
				(eval #'eval)
				(read #'read)
				(input *standard-input*)
				(output *standard-output*)
				(quit-fn #'null))
  "simple configurable REPL"
  (let (* ** *** - + ++ +++ / // /// vals)
    (loop
     (fresh-line output)
     (if (stringp prompt)
	 (princ prompt)
	 (funcall prompt))
     (setf - (funcall read input))
     (when (funcall quit-fn -)
       (return (values)))
     (setf vals (multiple-value-list (funcall eval -)))
     (setf +++ ++
	   /// //
	   *** (first ///)
	   ++ +
	   // /
	   ** (first //)
	   + -
	   / vals
	   * (first /))
     (dolist (value vals)
       (funcall print value output)))))
Source Context