[luatex] Behavior of node lists.

Hans Hagen pragma at wxs.nl
Sat Nov 10 12:28:41 CET 2012


On 11/10/2012 11:55 AM, Stephan Hennig wrote:

> Good point, too.  But let me ask again, the returned nodes are always
> the same as those given as arguments, with changed fields, but they
> never change identity?  That's not clear from the manual.

Sure, why should they change identity? Think of something like this (no 
head checking and such):

here.next = newnode
newnode.prev = here
if here.next then
   here.next.prev = newnode
   newnode.next = here.next
end

why should nodes become different nodes?

(maybe you think that a head node is something special, but it's not, 
it's just a name for the first node in alist)

> The node 'list' terminology is a bit confusing.  These node 'lists' are
> actually trees.  The latter having sub-trees with their own root (head)
> nodes etc.  A list, in contrast, usually has one invariant head node
> (putting aside operations that explicitly change a list head).  Even
> though I guess, for someone with a strong TeX background it is a trivial
> fact, I think the manual should be a bit more explicit about what head
> exactly to use in insert_before/after.

it's not invariant

head = tex.box[0].list

then mess with the list starting with head and in case of pushing 
something in front adapt the head variable and afterwards set:

tex.box[0].list = head

just linked lists (the concept in luatex is not different from other 
programming langauges)

the manual is not a 'tutorial in programming' and 'linked lists'; in 
fact: a programmer should recognize the concept but a tex macro writer 
might be somewhat confused as tex itself because there is talk like "the 
main vertical list" in manuals but on the other hand, once one starts 
messing with that one knows about the stuff (there is no access to the 
list at the tex end apart from some \last.. and \un.. operations and 
maybe un*box and vsplit resemble some messing list)

concerning a tree: indeed it is a tree with some nodes (not only hlist 
etc but also glyphs that are ligatures) being trees themselves

actually, the tex tracing primitives (showbox etc) will show you that 
kind of nesting in the log

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the luatex mailing list