Question

I have noticed that when I type an operator in REPL, it is often expanded into a value which has something to do with the input/output history.

Specifically I noticed that:

  • +, ++ ... expand to previous inputs,
  • *, ** ... expand to previous outputs,
  • - expand to the current input

There apparently are more (/ expands to something but I haven't figured it out exactly).

I've tried browsing the clisp docs, but unsuccessfully.

My questions:

  • What such magic REPL variables are also there? What do they do?
  • Is there a way to access Nth input or output (like IPython's In and Out arrays)?
Was it helpful?

Solution

The REPL variables are documented in the environment dictionary of the Hyperspec (search for "Variable"). The standard does not require holding any more of input/outputs than three, and I am not aware of any implementation that does it.

OTHER TIPS

As mentioned in the other answer, these variables are documented in the ANSI Common Lisp standard.

In addition to that a Common Lisp implementation may have lots of other features. A full featured top-level with user interface is often called a 'Lisp listener'.

The CLISP implementation provides additional commands in the debugger. See chapter 25 of its documentation.

LispWorks has some extensions in the REPL and also provides a Listener. Here are some examples:

Interaction number 2, in the CL-USER package:

CL-USER 2 > (* 3 4)
12

The same, but we can omit the outer parentheses:

CL-USER 3 > * 3 4
12

Let's redo interaction 2:

CL-USER 4 > :redo 2
(* 3 4)
12

Let's redo interaction 2, but with division instead of multiplication:

CL-USER 5 > :use / * 2
(/ 3 4)
3/4

Other implementations with extensions like commands, output histories, or similar features are for example Allegro CL and Clozure CL.

SLIME, which provides a Common Lisp development environment based on GNU Emacs, also provides an extended REPL.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top