Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: wierd REmove behavior

  • To: mathgroup at
  • Subject: [mg2372] Re: wierd REmove behavior
  • From: wagner at (Dave Wagner)
  • Date: Sun, 29 Oct 1995 22:48:56 -0500
  • Organization: University of Colorado, Boulder

In article <46pr4d$fve at>,
richard j. gaylord <gaylord at> wrote:
>one of my students came to see me and asked what was going on in the following.
>c = 6
>c = 6
>Remove[c];c = 6
>Information::notfound: Symbol c not found.
>Trace[Remove[c]; c = 6]
>{Remove[Removed[c]]; Removed[c] = 6, 
> {Remove[Removed[c]], Null}, {Removed[c] = 6, 6}, 6}

Someone from WRI may post a more authoritative answer on this one,
but here's my understanding of how this works:  When you type

	Remove[c]; c=6

the parser parses this input and looks up the symbol c in the symbol
table.  Both c's refer to the same symbol table entry.  The symbol
table entry has a reference count which in this case is at least two
(in fact, it's larger because of the earlier references to c).
Removing c marks the symbol table entry as removed, but because the
reference count is non-zero, doesn't actually remove the symbol
table entry from the symbol table.  The c=6 then refers to a
symbol table entry whose name is "c" but which has been removed,
hence it prints as "Removed[c]".  This is a pathological beastie
that it's very hard to do anything useful with.

The same type of behavior is going on when you do something like this:

	x = 6;
	temp`x = 7;

Now if you evaluate x you will get 6; if you evaluate the following:


you will get 7.  BUT if the following will give you 6 again:

	Begin[temp`]; x

Because all of the symbols are looked up in the symbol table before
the context-changing command is executed.

Anyway, this reminds me of an old joke:  A guy goes to the doctor,
he says, "Doc, it hurts when I do this."  So the doctor says,
"Then don't do that!"

		Dave Wagner
		Principia Consulting
		(303) 786-8371
		dbwagner at

  • Prev by Date: Speed foe Mma ans Win95
  • Next by Date: Paolo's question
  • Previous by thread: wierd REmove behavior
  • Next by thread: Plotting Dynamic Flows on Simplex