Index  Comments

Ofttimes, a programmer needs the link field of a data structure to be able to express the absence of a link. There are conventional and unconventional ways to do this, as are there good and poor ways.

The most obvious way to express this is through a flag, indicating whether the link be valid or not. This has the most obvious downside of using a flag, regardless of how often it will truly be needed. A less obvious but more common way to express this is through a special link value, meaning nothing. This avoids wasting much space, using a fraction of what a flag would, but I've encountered cases in which there be no space to waste; also, it requires constant vigilance in seeking the special links.

By making the mechanism slightly more complex, a potentially nicer way to signal this becomes known. There's almost always a single link which may be used safely, that link to itself. By merely making the mechanism aware of its link, this termination technique becomes possible; a related mechanism is avoiding termination entirely, by making all links ultimately circular, and this avoids some issues, when it be done correctly so one may depend upon it. These four techniques seem to be rather total.

A practical example of this aforementioned constraint came to me when mulling over tables of Elision codes: I may want to have a table in which every index corresponds to a word and in which all values correspond to a synonym, translation, or some other such thing. This scheme leaves no room for that nothing value, and a flag for such is such a waste. However, so long as I may structure the problem so that a value may be its own synonym or the like, I needn't waste space, and I may also store many such relations using the same space per word, by using circular lists; this nicely solves the issue.

I won't blindly believe in the use of special links now; special situations can avoid special links.