3

For a key keya defined by

\define@key{fam}{keya}[\def\y#1{#1}]{\def\x##1{##1x#1}}

the keyval package uses

\def\KV@def#1#2[#3]#4{%
  \begingroup\toks@{#3}%
  \xdef\@gtempa{\expandafter\noexpand\csname KV@#1@#2\endcsname{\the\toks@}}%
  \endgroup
  \expandafter\let\csname KV@#1@#2@default\endcsname\@gtempa
  \expandafter\def\csname KV@#1@#2\endcsname##1{#4}%
}

to define the default value as

\KV@fam@keya@default{\KV@fam@keya{defau}}

This style of defining the default value is called the standard format by the xkeyval package. Packages such fancyvrb don't adhere to this standard. The xkeyval package says that such packages abuse the default-value format.

I have always wondered why the keyval package chose to define the default value of a key in this way, instead of the apparently cheaper approach of storing the default value in a macro like

\def\KV@fam@keya@default{defau}

Without eTeX this should actually be

\newtoks\toksa
\toksa{defau}
\edef\KV@fam@keya@default{\the\toksa}

or something similar.

3
  • 4
    Where is the question? Why don't you accept any of your questions. Feb 5, 2012 at 0:07
  • Where is the question? Wait for David Carlisle! Please I have clicked on the 'accept' mark/button but the red warning will not disappear.
    – Ahmed Musa
    Feb 5, 2012 at 0:13
  • @AhmedMusa: Be sure to not to close the page too early after clicking (give it a few seconds). If you have JavaScript disabled or blocked, enable it. Feb 5, 2012 at 0:23

1 Answer 1

5

"Why" answers are always hard to answer, especially decades after the fact. I think that the original motivating examples that I was trying to pull into a common key-value system included cases where the "default" action didn't correspond directly to passing a value to a key, invoking a separate ..@default command name means that the default case can be defined to do essentially anything.

1
  • David: Thanks. This rather trivial question has led me to something in ltxkeys package.
    – Ahmed Musa
    Feb 5, 2012 at 17:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .