title: TeX edef macro blues
body: <p>I spent some time trying to write a 'helper' macro to test a parameter for a new value, else use the existing value -- default values exist for all parameter positions.</p>
  
  <p>I wanted to be able to write:</p>
  
  <pre><code>\foo{left}{nil}{}{20pt}
  </code></pre>
  
  <p>so that the second parameter would used its current value but the third value would be the value empty string. I wanted to use the notation:</p>
  
  <pre><code>\edef\pA{\isnil{#1}{\pA){#1}} % one for each parameter
  </code></pre>
  
  <p>I defined \isnil like so:</p>
  
  <pre><code>\def\nil{nil}
  \def\isnil#1#2#3{%
    \edef\nilTest{#1}%
    \ifx\nilTest\nil#2\else#3\fi
  }
  </code></pre>
  
  <p>but when I tried to run it, TeX complained that \nilTest is an undefined control sequence.
  That is true of course, but I want \pA to hold a value, not a recipe for a value, so it must be an \edef which means that all the macro test will be expanded but while will the \edef not protect the \nilTest -- is this a place to use \noexpand -- that did not seem to work for me.</p>
  
  <p>EDIT: no digits in \cs names (yeah, I knew that.)</p>