(1) In the expression
\def\pgfkeysgetvalue#1#2{\expandafter\let\expandafter#2\csname pgfk@#1\endcsname}
#2 will be let to \relax whenever pgfk@#1 is undefined. Is this harmless in pgf? Even if it was benign, why isn't a more formal coding style adopted.
(2) In the expression
\def\pgfkeysvalueof#1{\csname pgfk@#1\endcsname}
\pgfkeysvalueof{#1} will be simply \relax if the name pgfk@#1 was undefined. The arguments of \csname pgfk@#1\endcsname will then be unabsorbed (and, eg, will result in \@nodocument outside LaTeX document environment). Why isn't it necessary to first check for the existence of the name pgfk@#1?
(3) Why wasn't the following expression made more compact by a simple abstraction?
\long\def\pgfkeysdefnargs@#1#2#3#4{%
\ifcase#2\relax
\pgfkeyssetvalue{#1/.@args}{}%
\or
\pgfkeyssetvalue{#1/.@args}{##1}%
\or
\pgfkeyssetvalue{#1/.@args}{##1##2}%
\or
\pgfkeyssetvalue{#1/.@args}{##1##2##3}%
\or
\pgfkeyssetvalue{#1/.@args}{##1##2##3##4}%
\or
\pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5}%
\or
\pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6}%
\or
\pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6}%
\or
\pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6##7}%
\or
\pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6##7##8}%
\or
\pgfkeyssetvalue{#1/.@args}{##1##2##3##4##5##6##7##8##9}%
\else
\pgfkeys@error{\string\pgfkeysdefnargs: expected <= 9 arguments, got #2}%
\fi
...
}
Here is a pseudocode for the abstraction I mean:
initialize \pgfkeys@temptoks, \pgfkeys@tempcnta
\loop
\advance\pgfkeys@tempcnta\@ne
\edef\x{%
\pgfkeys@temptoks{\the\pgfkeys@temptoks\ifnum\pgfkeys@tempcnta
<\numexpr#1+1\relax<parameter chars>\the\pgfkeys@tempcnta\fi}%
}\x
\ifnum\pgfkeys@tempcnta<#1\relax
\repeat
Here, you can avoid eTeX if you like.
ifcaserather than a\loop..\repeat. – yannisl Apr 17 '12 at 19:18