[luatex] Behavior of node lists.

Stephan Hennig stephanhennig at arcor.de
Thu Nov 8 22:34:54 CET 2012

Am 08.11.2012 09:38, schrieb Paul Isambert:
> Selon Taco Hoekwater <taco at elvenkind.com>:
>> On 11/07/2012 07:37 PM, Stephan Hennig wrote:
>> > Am 06.07.2011 15:43, schrieb Taco Hoekwater:
>> >> On 07/04/11 09:06, Paul Isambert wrote:
>> >>>
>> >>> The manual says you're in charge of ensuring that in
>> >>> "node.insert_after(H, N, x)", N is in the list denoted by H. The thing
>> >>> is, H doesn't seem to matter at all, unless it's nil:
>> >>
>> >> Actually H is also useful if N is nil (that is a tail-append the list
>> >> that starts at H), but it is true that H is generally unused.
>> >
>> > If N is known to be non-nil, e.g., a glyph node, is it save to call
>> >
>> >    node.insert_after(nil, N, x)  ?
>> >
>> > If the answer is 'Yes',
>> Well, yes. However I do not like the idea of reordering the
>> arguments, because we have quite a lot of functions with 'head'
>> argument, and they always come first.
> I definitely agree (don't want to rewrite umpteen files).

Come-on!  There might be umpteen TeX and LaTeX files, but no Lua code
files that use node.insert_after.

> Plus the optionality of the head makes less sense than the
> optionality of the current node, even if it were more frequent; it'd
> mean you have to check beforehand whether the current node exists or
> not before you use the function.

Well, in my use-case, current is always a valid node.  So I wondered why
head were needed at all.  But your use-cases might differ.  But then
again, current has to be checked for being nil anyway (even if that is
hidden in the function).

> If the head is a mandatory argument, you just don't ask question.

I think inserting a node at the end of a given head node is something
different than inserting a node exactly after a given node.  I you want
to do the former, you could always say

  insert_after(node.tail(head), new)

Best regards,
Stephan Hennig

More information about the luatex mailing list