\def\macro{\ifincsname relax\else Hello\fi}
\def\MACRO{\csname macro\endcsname}
\csname\macro\endcsname
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
{\csname}
\macro ->\ifincsname relax\else Hello\fi
{\ifincsname: (level 1) entered on line 34}
{true} < -------------------- O.K.
{\else: \ifincsname (level 1) entered on line 34}
{\fi: \ifincsname (level 1) entered on line 34}
{\relax} < -------------------- O.K.
{\par}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
\csname\MACRO\endcsname
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
{\csname}
\MACRO ->\csname macro\endcsname
{\csname}
\macro ->\ifincsname relax\else Hello\fi
{\ifincsname: (level 1) entered on line 37}
{false} < --------- Feature or bug ???
{\else: \ifincsname (level 1) entered on line 37}
{\fi: \ifincsname (level 1) entered on line 37}
{changing \Hello=undefined}
{into \Hello=\relax} < ------------------- ??
{\relax}
{\par}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Thanks.
(I'm embarrassed by this behaviour ...)
I check the eTeX manual, and \ifincsname is provided by XeTeX and pdfTeX...
\def\macro{\ifincsname relax\else Hello\fi}
\def\MACRO{\csname macro\endcsname}
\def\MaCrO{\macro}
\csname\macro\endcsname -> \relax
\csname\MaCrO\endcsname -> \Hello
\csname\MACRO\endcsname -> \Hello
???
Yours sincerely.
\def\macro{\ifincsname relax\else Hello\fi}
since :
\def\MaCrO{\ifincsname\macro\else\macro\fi}%
\def\MACRO{\%
ifincsname \csname macro\endcsname
\else \csname macro\endcsname\fi
}%
behave differently: \MaCrO has the expected behaviour:
{\csname}
\MaCrO ->\ifincsname \macro \else \macro \fi
{\ifincsname: (level 1) entered on line 38}
{true} <------------ O.K.
\macro ->\ifincsname relax\else Hello\fi
{\ifincsname: (level 2) entered on line 38}
{true} < ---------- O.K.
{\else: \ifincsname (level 2) entered on line 38}
{\fi: \ifincsname (level 2) entered on line 38}
{\else: \ifincsname (level 1) entered on line 38}
{\fi: \ifincsname (level 1) entered on line 38}
{\relax}
{\par}
while \MACRO finally expands \csname Hello\endcsname.
This gives a turn around, not difficult to write:
\ifincsname\macro\else\macro\fi
works ! ;-)
The bug had been spotted this summer on the XeTeX list, and Will
Robertson reported it on the pdfTeX list, but I don't know if any
correction was made.
Best,
Paul
Correction: it was fixed in December (see pdfTeX's svn), and I suppose
it'll be included in TL2011 and the next MikTeX.
Best,
Paul
Yes thanks !
\def\macro{\ifincsname relax\else Hello\fi}
\def\MaCrO{\expandafter\@firstofone\csname macro\endcsname}
Does not work either: it appears that \ifincsname is redefined
each time it sees a \csname, while the switch should be global,
set to true while entering the first \csname until the matching
\endcsname...
Anyway, i'm getting on with \ifincsname\macro\else\macro\fi !
Just this is a bit silly ;-)
Thanks again.
>
> Best,
> Paul
> Le 28/01/2011 16:08, zappathustra a écrit :
>> Le 28/01/2011 16:05, zappathustra a écrit :
>>> Le 28/01/2011 16:03, GL a écrit :
>>
>> Correction: it was fixed in December (see pdfTeX's svn), and I suppose
>> it'll be included in TL2011 and the next MikTeX.
>
> Yes thanks !
>
> \def\macro{\ifincsname relax\else Hello\fi}
> \def\MaCrO{\expandafter\@firstofone\csname macro\endcsname}
>
> Does not work either: it appears that \ifincsname is redefined
> each time it sees a \csname, while the switch should be global,
> set to true while entering the first \csname until the matching
> \endcsname...
Do you think it should be true in
\csname\number\ifincsname
I am not all too convinced of that. I am not all too convinced there is
a good consistent definition and behavior, either...
--
David Kastrup
UKTUG FAQ: <URL:http://www.tex.ac.uk/cgi-bin/texfaq2html>
My position is: TeX makes things in a sequence, one after another. Thus,
at any point of the compilation, you can say if you are building a cs
name of not, \ie if you are in a \csname ... \endcsname "group".
\csname \number\ifincsname is true, otherwise what whould be the meaning
of \ifincsname ???
And I have another example of absolutely no interest:
\ifcsname \ifincsname relax\else @undefined\fi\endcsname
ifincsname returned true
\else
ifincsname returned false
\fi
=> returned false, which is normal...
Regards.