Reset state in Common Lisp
Asked Answered
R

2

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)

Roehm answered 16/9, 2010 at 10:6 Comment(1)
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-dieRuthful
C
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.

Cassondra answered 16/9, 2010 at 11:3 Comment(1)
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).Fumed
H
-1

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

Her answered 3/8, 2012 at 18:27 Comment(1)
That just deletes the output, while the OP asked for a way to reset state, like uninterning symbols etc.Seedcase

© 2022 - 2024 — McMap. All rights reserved.