[luatex] Behavior of node lists.

Stephan Hennig mailing_list at arcor.de
Sat Nov 10 11:55:48 CET 2012


Am 09.11.2012 21:44, schrieb Hans Hagen:
> On 11/9/2012 8:48 PM, Stephan Hennig wrote:
> 
>> | The return values are the (potentially mutated) head and the node
>> | new, set up to be part of the list (with correct next field).
>>
>> Does that mean, after calling insert_after, head and new can be
>> different nodes that that given as argument to the function?  If only
>> fields in the original nodes are updated, what's the purpose of
>> returning the nodes again?
> 
> after and before have a consistent similar interface so you can make 
> 'generic' functions that get insert_before or insert_after passed, so 
> it's mostly about consistency in interfaces

Good point.  Would be good to have that in the manual.


> the advantage of passing head to insert_after is that when head is nil 
> at the start of whatever you do, you get a head back:

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.


>> Second, when inserting nodes into a deeply nested node list, is the head
>> argument to insert_after the head of the current branch (latest hlist or
>> vlist head) or the top-level head of the node list?
> 
> always the head of the 'current' list

This is what I assumed.  Thanks!

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.

Best regards,
Stephan Hennig



More information about the luatex mailing list