Print

Print


On 11/11/2010 12:06, Rémy Oudompheng wrote:
> Another l3keys puzzle : the following code
>
> \documentclass{minimal}
> \usepackage{expl3}
> \begin{document}
> \ExplSyntaxOn
> \keys_define:nn {module} {
>    a .default:n = Alice ,
>    a .code:n = Hello #1 ,
> }
> \keys_set:nn {module} {a}
> \ExplSyntaxOff
> \end{document}
>
> produces "Hello ", but if I swap the "default:n" and "code:n" line, I
> get "Hello Alice".
>
> The example from the documentation (latex3-source.pdf) also puts the
> "default:n" line last. Is that mandatory ?

At least in the current implementation, .code:n will 'reset' any other 
properties of a key. So setting "a .code:n = Hello #1" will delete any 
default value. I guess that this needs more explanation.

Now, you might wonder why this happens. The thinking when I wrote this 
was that if you change the code in some arbitrary way then any other 
properties may no longer be valid. For example, if you do something like

   a .value_forbidden: ,
   a .code:n = Hello #1 ,

then it's not exactly obvious what should happen about 'forbidden' property.
-- 
Joseph Wright