On Thursday, 10 November 2005 11:09:46 +0100,
Heiko Oberdiek <[log in to unmask]> writes:
> On Thu, Nov 10, 2005 at 09:03:16AM +0100, Uwe Lück wrote:
> > At 07:52 10.11.05, Will Robertson wrote:
> > >Finally, somehow the topic of extensions to pdf-e-TeX came up, and
> > >there were some naive comments from me and some interesting comments
> > >from Morten. I proposed the idea of something like \previouschar,
> > >which we interpreted in two separate ways:
> > >
> > > - it "would return the slot number of the most recently seen char
> > >or ligature node independently of whether we just saw a glue node or
> > >another char/lig node; any other node type could reset it to
> > >-1" [morten]
> > >
> > > - it would actually be more like LaTeX's \@ifnextchar, and look at
> > >the input token list [me]
When looking at the way ((pdf)e)TeX works, Morten is right ... and the
name \previouschar of the control sequence is misleading:
a) TeX is reading _characters_ from files/stdin which get converted
b) When these tokens are dealt with by TeX's main control loop where
the typesetting is done, the _tokens_ are triggering the building
Within the TeX macros language, it is not really possible to access
_characters_. You can only get access to _tokens_ and _nodes_ and
The other problem is that the typesetting process (tokens -> nodes)
introduces an asymetry:
- If you want to look forward, you access _tokens_.
- If you want to look backward, you access _nodes_.
> > >Implicit in my thinking was that you could also eat up previous chars
> > >in the same was as \unskip with a sort of fine-grained \lastbox; to
> > >which idea Morten replied:
> > >
> > > This is exactly what some languages need.
> > >
> > > Since there are so many different node types the only safe
> > > (IMO) way is to backtrack one node at a time so ideally we
> > > would want the pair \lastchar and \unchar. And then we might
> > > as well get one for each different node type. I guess someone
> > > has to come up with a good idea about what to do with \discretionary
> > > because I'm not at all sure what the semantics should be.
e-TeX provides the new primitive \lastnodetype to query the type of
node in the current node list. What's missing and what was thought
about was a set of additional primitives \last... similar to \lastbox,
\lastpenalty, \lastkern, \lastskip to get access to (and remove) all
possible type of nodes.
This was postponed for e-TeX because (a) the implementation will be
rather tricky for e.g., special nodes and in some contexts where the
result of real arithmetic can be accessed (e.g., \accent
constructions) which will lead to implementation dependend behaviour.
And (b) additional data types has to be introduced for (e-)TeX to be
able to save all different kind of nodes.
> > by accident, this occurred to me as well, if only for a
> > rather fun application. \lastchar
> And what kind of object is the return value of \lastchar?
> A number is quite useless, because this misses the font property.
Better use the name \lastcharnode (or \lastglyphnode?) and it will
return a _charnode_ which is a data type consisting of atleast a glyph
position and a font ... and probably other properties?
Former member of the e-TeX team.