Message Boards Message Boards


Beware \[Null] and other invisible characters.

Posted 9 years ago
1 Reply
1 Total Likes

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


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


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.

POSTED BY: Brian Beckman

Yes, invisible characters can be treacherous. On the other hand, in mathematical text, the [VeryThinSpace] can be useful in getting better formatting.

POSTED BY: Murray Eisenberg
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract