[texhax] FW: Re: Implementing control sequences with key values
Paul Isambert
zappathustra at free.fr
Tue Nov 16 11:37:03 CET 2010
Le 15/11/2010 13:57, Uwe Lueck a écrit :
> "Paul Isambert"<zappathustra at free.fr>, 15.11.2010 12:34:36:
>> Le 14/11/2010 22:47, Uwe Lueck a écrit :
>>> Correcting my 14.11.2010 19:02:33:
>>>>> Wolfgang Schuster wrote:
>>>>>> \def\direction#1=#2#3
>>>>>> {\def\currentdirection{#2#3}}
>>> I commented:
>>>> Wolfgang's code is redundant both in the definition and testing.
>>>> The core of his idea is:
>>>> \def\direction=#1 {\def\currentdirection{#1}}
>>> But
>>>
>>> \def\direction=#1#2 {\def\currentdirection{#1#2}}
>>>
>>> is superior in allowing ("optional"!) spaces after "="
>>> in using \direction.
> PI> And Wolfgang's original
> PI>
> PI> \def\direction#1=#2#3 {...}
> PI>
> PI> also allows optional space before "=", which might happen under some
> PI> circumstances.
>
> My previous posting was the result of carefully checking this,
> it turns out that the parameter at the left of "=" is not needed
> for allowing
>
> \direction = RTL
>
> it already works with my suggestion above.
> I did post code that demonstrated this --
> finally this is anyway clear from TeX's parsing rules
> (under usual catcodes):
> "=" is the next token after \direction that TeX realizes
> (I am unable to learn the "mouth/stomach" terms
> for a better explanation right now, and cannot
> look up the TeXbook chapter, I think this happens
> already at tokenizing, i.e., the tokenizing function
> is TeX's only part that knows about spaces after
> "\direction".).
>
> So the "#1=#2#3" really is redundant, I only admitted
> that it is not as redundant as I had claimed before.
The "circumstances" I had in mind are more contrived, e.g. \direction
being the result of expansion:
\def\whatever#1{...\direction}
\whatever{...} = RTL
To mimick assignments you need the first argument, otherwise \direction
won't match its definition.
Best,
Paul
More information about the texhax
mailing list