# Does \let\a=\a do anything more than \relax?

Poking around with \show (and \loggingall) in the TikZ code, I see that the definition of \tikz@command@path (which \path is \let to inside tikzpictures) starts with

\let \tikz@signal@path =\tikz@signal@path


Is that doing anything? The only possibilities I see are an \afterassignment trickery, or a very unlikely use of \global.

\RequirePackage{tikz}
\makeatletter
\show\tikz@command@path


or, to see that this is the definition of \path also,

\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikz{\show\path}
\end{document}

-
It surely blocks the premature expansion of \pgfutil@ifnextchar were it in an alignment; but \relax would do the same. There's also \def\tikz@signal@path{\tikz@signal@path} on line 1540 of tikz.code.tex. Yuk! –  egreg Jun 20 '11 at 20:46
@egreg: Doing \def\foo{\foo} is actually useful. You can use it with \futurelet as a sentinel to process everything up to the \foo. As a side effect, if you get something wrong and \foo gets expanded, the infinite loop that results is a good way to figure out that something has gone horribly wrong. –  TH. Jun 20 '11 at 20:54
@TH: I didn't say it's useless. –  egreg Jun 20 '11 at 21:11
@egreg: it could be a dummy assignment to trigger a previous \afterassignment, but that seems like a very dirty trick. –  Bruno Le Floch Jun 20 '11 at 21:31
The only other place \tikz@signal@path is used is at line 41 of tikzlibrarymatrix.code.tex in the execute at begin cell code for matrix of nodes. As far as I can tell, it is there to check whether the matrix cell contents start with a path, so that a normal matrix cell is created instead of a new node. –  Caramdir Jun 21 '11 at 10:34

As far as I can tell, this is used to be able to tell where a path is started. The string \tikz@signal@path shows up again in line 41 of tikzlibrarymatrix.code.tex.

My interpretation of the code (which might be wrong!) is that the following happens to construct a cell in a matrix with the matrix of nodes option:

• First the general matrix code starts setting up the cell.
• The code at execute at begin cell is executed. In particular, matrix of nodes hooks into this mechanism.
• TikZ tries to be smart about creating a node for this cell:
• if the cell content starts with | then it creates a new \node with the things delineated by | as options (and anything afterwards passed as node content);
• if the cell starts with a TikZ path then no node is created, and the cell is processed completely by the pgf code;
• otherwise it just creates a node with the cell contents.
• PGF continues processing the cell.

The problem here is how to check whether the cell contents start with a TikZ path. This is done by checking for the presence of \let\tikz@signal@path at the start of the content.

So, to answer your question, the \let \tikz@signal@path =\tikz@signal@path does nothing (useful) when executed as part of a path, but serves as a signal to anything inspecting the code that the following code is part of a path.

-
Very neat piece of investigative TikZalism. –  Loop Space Jun 21 '11 at 18:54
Thank you @Caramdir for the great answer. You may want to add that \let\tikz@signal@path=\tikz@signal@path does nothing per se, but is just there to be a recognizable "do-nothing". –  Bruno Le Floch Jun 21 '11 at 20:33