# How to use the primitive \the with dimen?

I know that I need to put an internal quantity after \the. I know the expansion is a list of tokens of catcode 12 (except for space characters). I know the next problem :

\skip0=30pt plus 2pt\relax
a\hskip\the\skip0 minus 1pt b
a\hskip\skip0 b
a\hskip\skip0 minus 1pt b


but in the sources of pgf/tikz, I see for example

\def\pgfgetlastxy#1#2{%
\edef#1{\the\pgf@x}%
\edef#2{\the\pgf@y}%
}%


\pgf@x is often preceded by \the. Why is the necessary in such cases? Do you know an example with a problem ?

The \pgf@x and \pgf@y registers are temporary ones which are changed frequently. Using \the inside \edef stores the current value of them as string into a normal macro, so that value(s) can still be used elsewhere after the registers are already changed again.
Simply using \def#1{\pgf@x} would make the macro given as #1 a synonym for \pgf@x which would not give you any benefits.