In Common Lisp, it is used by the reader and printer.
Thus, you can mark an object in some s-expression and refer to it elsewhere in the s-expression.
Label #someinteger= followed by an s-expression. An integer must be unique. You cannot use a label twice in the same s-expression.
Link to the label #someinteger# . An integer identifies the s expression for the reference. A label must be entered before it can be referenced. A link can be used several times in an s-expression.
This, for example, is used to read and print circular lists or data structures with shared data objects.
Here is a simple example :
? '(
read like
((1 . 2) ((1 . 2)))
Pay attention also to this:
? (eq (first *) (first (second *))) T
This is one identical cons cell.
Try the circular list .
Make sure the printer deals with circular lists and does not print them forever ...
? (setf *print-circle* t) T
Now we create a list:
? (setf l1 (list 1 2 3)) (1 2 3)
We install the last cdr in the first cons:
? (setf (cdr (last l1)) l1)
As you can see above, the printed list gets the label, and the last cdr is a link to this label.
We can also enter a circular list directly using the same notation. The reader understands this:
? '
Since we said that the printer deals with such constructions, we can try the expression from the first example:
? '(
The printer now detects two references to the same cons object.