29

Newbie Common Lisp question here.

Is there a way to reset the state of the environment? What I mean, is there some command that brings the REPL back to the same state it was right after it started up, that is, uninterning all variables, functions, etc. Or if that's not in the Common Lisp standard, is there some extension in SBCL (the implementation I use) to do that?

(EDIT: I know that in SLIME, M-x slime-restart-inferior-lisp does that but I wonder if there's a way without restarting the process)

Tamas Czinege
  • 118,853
  • 40
  • 150
  • 176
  • Not an answer, so I'm putting it in a comment: I don't know exactly why you're asking this question, but you might be interested in making a core dump of a Lisp image in a "clean" state (I, personally, would at least load Quicklisp first, but that's up to you) and then loading that; you can do it in SBCL with [`sb-ext:save-lisp-and-die`](http://www.sbcl.org/manual/#Function-sb_002dext_003asave_002dlisp_002dand_002ddie) – fouric Feb 24 '18 at 23:21

2 Answers2

25

Not in general, no. I occasionally want to do something like that, so my workflow is generally to create a new package to hold whatever project I'm starting, then when I want to reset things I use DELETE-PACKAGE. I never do any work in the CL-USER package, since different implementations have different things stuffed into it.

Xach
  • 11,774
  • 37
  • 38
  • While it makes sense to do that - ultimately, it is kind of a work around for some non-existing "restart-package". When I answer SO questions for example, I have one-off small lisp files I work on and once I am done and turn to the next question, I either have a contaminated CL-USER or have to restart the inferior lisp altogether (and quickload my usual libraries). – BitTickler May 28 '21 at 14:14
-1

Use C-c M-o, as given in REPL menu's Clear Buffer

Sweet Kid
  • 15
  • 1
  • 4
    That just deletes the output, while the OP asked for a way to reset state, like uninterning symbols etc. – danlei Aug 04 '12 at 05:57