[tex-k] implementation of \scantokens
spotje at gmail.com
Wed Nov 30 09:00:01 CET 2005
I have a small comment on the implementation of \scantokens. Let me
stress that I didn't look at the source, but found this when
programming some algorithm.
I was programming a method to read material verbatim and write it to
file for later use. It should work in the environment of powerdot
output from lyx, which looks like
\lyxbegin should start reading verbatim, until it meets \lyxend. Then
switch to normal mode and execute anything that is left on the line.
The easiest is to read entire lines. But then the second \lyxbegin
should be read again to assign proper catcodes for execution and start
a new verbatim session. This seems to be the perfect example for the
use of \scantokens. However, it doesn't work here as that works with
an internal file operation, meaning that also an eof will enter the
input stream and the verbatim macros can't handle that.
The examples below demonstrate this problem. The first example
attempts an \input, which fails when parsing the line with the eof.
The second attempts \scantokens, which we might expect to work here,
but it doesn't as described above. The third example provides a very
cumbersome but working alternative (conditionally on the fact that we
know that we only wrote a single line that should be executed!).
Can't \scantokens be implemented to really put material back in TeX's
mouth for new catcode assignments? Of course, it will be a bit slower,
but then these unpleasant things won't happen anymore.
Thanks, best regards,
More information about the tex-k