Am 08.11.2012 23:09, schrieb Hans Hagen: > On 11/8/2012 10:21 PM, Stephan Hennig wrote: > >> That is, the first argument <head> is actually never needed. Though, on > > maybe in your code, but in mine it's needed in most cases
Interesting, could you please give a use-case? Mine is to insert whatsit nodes to store additional information in a node list. And I'm inserting that only behind valid nodes. Then I was puzzled seeing head is needed to insert a node, which is (now was) not available at that point. > you can consider wrapping it in a helper: > > function i_a(n,current,head) > return node.insert_after(head,current,n) > end No, I've changed my code so that head is available now. Two follow-up questions: Only after my initial post I have seen that insert_before and insert_after return head and new. To quote the manual: | 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? 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? Best regards, Stephan Hennig
