What are the magic variables in CLISP's REPL?
Asked Answered
C

2

5

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)?
Camire answered 2/1, 2012 at 10:12 Comment(2)
wow! I didn't know IPython's In and Out arrays, thanks!Argyle
It also has shorthands _, __ ... which mean Out[-1], Out[-2] etc.Camire
H
7

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.

Hamite answered 2/1, 2012 at 10:51 Comment(0)
H
3

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.

Hadik answered 2/1, 2012 at 11:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.