Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the magic variables in CLISP's REPL?

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)?
like image 950
Kos Avatar asked Jan 02 '12 10:01

Kos


2 Answers

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.

like image 170
Ramarren Avatar answered Nov 13 '22 12:11

Ramarren


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.

like image 3
Rainer Joswig Avatar answered Nov 13 '22 10:11

Rainer Joswig