## LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

 Options: Use Forum View Use Monospaced Font Show Text Part by Default Show All Mail Headers Message: [<< First] [< Prev] [Next >] [Last >>] Topic: [<< First] [< Prev] [Next >] [Last >>] Author: [<< First] [< Prev] [Next >] [Last >>]

 Subject: Re: Robustness (was Re: Expandable templates) From: Frank Mittelbach <[log in to unmask]> Reply To: Mailing list for the LaTeX3 project <[log in to unmask]> Date: Mon, 25 Oct 1999 20:40:02 +0200 Content-Type: text/plain Parts/Attachments: text/plain (85 lines)
Javier,

> The "expandability" of \add@accent has not changed. It is still
> expandable, if its definition is:
>
>    \setbox\@tempboxa\hbox{#2%
>       \global\mathchardef\accent@spacefactor\spacefactor}%
>    \accent#1 #2}\spacefactor\accent@spacefactor}
>
> The problem is that \accent@spacefactor is not yet defined in \edef's
> prior to an actual use of any accent. That is a LaTeX bug which can be
> fixed by letting \accent@spacefactor to \relax or by defining
> it with \mathchardef (in both cases it expands into itself).

this is an interesting point (what you are saying is some assignments are
harmless as they do not fail horribly even though they do not expand really
and all we have to do in that particular case is making sure that we keep the
status of that macro expansion this way).

agreed, but as you will be aware this wasn't really the point that i was trying
to make (and it doesn't make my point invalid either). the point was that
there are macros containing dangerous assignments (mostly internal \def's or
\let's) which will die horribly if put into an \edef

and my claim is that without the LaTeX protection mechanism (which essentially
prohibits the use of \edef everywhere where the content of \edef is not fully
controlled by the macro writer) there is no cure for this problem:

a) you need macros containing dangerous assignments (containing \let say)

b) current coding practice in TeX does need the functionality of \edef

now the LaTeX solution right now is to say: don't use edef use \protected@edef
and friends and all is well.

my question was, are there better approaches?

(the plain TeX approach by the way is: know your macros and don't use them in
a way that you end up expanding such a dangerous beast inside an \edef :-)

> Example:
>
> \documentclass{minimal}
>
> \edef\agrave{\a}  % Doesn't work
> \setbox0\hbox{\a} % We use an accent
> \edef\agrave{\a}  % Now it does work (but \agrave looks horrible! :-) )

run like that it unfortunately doesn't show your point but rather shows mine

as you will get:

[ some tracing omitted ]

\?\ ->\UseTextAccent {OT1}\

\UseTextAccent #1#2#3->\let \@curr@enc \cf@encoding \@use@text@encoding {#1}#2{
\@use@text@encoding \@curr@enc #3}\@use@text@encoding \@curr@enc
#1<-OT1
#2<-\
#3<-\fi
{undefined}
! Undefined control sequence.
\UseTextAccent #1#2#3->\let \@curr@enc
\cf@encoding \@use@text@encoding {#1}...

in other words we never reach the case of the \accent@spacefactor but die in
\UseTextAccent which already contains a \let and does expand in this way if
used in \edef in contrast to \protected@edef (where it would behave correctly)

so i think my questions are still valid and i wonder if i get some more
feedback

best
frank

ps which does not mean that we shouldn't fix the kernel to have a definition
for \accent@spacefactor