A brief debugging story -- I lost several hours fenceposting a bug, which turned out to be hard to find.
I had been typing many expressions of the form
Append[someSet, Null]
I decided it would be nice to have an infix operator for Append
, so I defined
CircleDot = Append
and rewrote many of my prior constructs as
someSet [CircleDot] Null
which, of course, prints very prettily in my notebooks. I then had some unrelated intermediate results that cause me to doubt my decision, so I backed out some of the circle-dot notations. One, in particular, was inside a call
someFunction[someSet[CircleDot]Null]
I put the cursor to the right of the circle dot or its coded form (I can't remember) and began to backspace. The Null disappeared! I thought it was just an editor glitch, so I just typed it back in. I later found out that what happened is that somehow the editor saw [Null]
and replaced it with an invisible character. The actual value in my expression was
Times[[Null],Null]
which just prints as Null
; the \[Null]
is all-but-invisible. All this was deep down in a function, and the ramifications only appeared at much higher levels. In particular, it appeared that
Union[{1, 2, 2}] ~~> {1, 2, 2}
Only FullForm revealed that the real set was
{1, 2, Times[2,[Null]]}
which had pulled itself up from deep inside my system. It took me a long time to diagnose because I had to strip things away one layer or piece at a time and to construct small examples (the real data had 10's of thousands of elements) and then applying FullForm
when results didn't make sense. I really had no idea what was wrong until the very end, when I was preparing a repro notebook to submit as a bug report.