Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Not sure if posted before, but I'm asking this question from a Mathematica fellow user who tried to load expressions, whose problem soon turned into a prison break game featuring the following code.

SetAttributes[hold, HoldAllComplete];
GetOut /: hold[GetOut] := Unset[$Pre];

$Pre = hold;

After executing this code, all subsequent evaluations are hold, including the GetOut "key" and the reset expression.

$Pre = .

Are there any ways to unhold subsequent evaluations, in addition to rebooting Mathematica?

share|improve this question
Are you looking for a good solution, or the user's physical integrity should be preserved? – Dr. belisarius Oct 26 '13 at 2:36
@belisarius Definitely both, if possible. I don't feel like hurting executed evaluations preceeding the lock. – FrenzY DT. Oct 26 '13 at 2:39
Good question. I've always just restarted my kernel when I bungle up $Pre or $PreRead, since I didn't think there was any other way around. Would be interesting if there was... – R. M. Oct 26 '13 at 2:46
@rm-rf It's interesting that once we change HoldAllComplete to Hold, both the original attempts work. – FrenzY DT. Oct 26 '13 at 2:49
Ooh... I have a way out. Writing an answer. – R. M. Oct 26 '13 at 2:52
up vote 6 down vote accepted

There's nothing that can break out of a HoldAllComplete as long as it has to pass through the kernel. But what if we had a way to bypass the kernel? Hmmm... buttons!

I suggest using the following button as an escape mechanism instead of your GetOut:

Button["Clear $Pre", Unset[$Pre]]

With this, you can clear $Pre by simply clicking it — even with the HoldAllComplete. It works because the evaluation is done via the Front End and not the kernel, thus bypassing $Pre.

share|improve this answer
How does the Button function get evaluated? Is it through the Front End? – FrenzY DT. Oct 26 '13 at 4:34
@FrenzYDT. Read the last paragraph? – Sjoerd C. de Vries Oct 26 '13 at 6:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.