- Notifications
You must be signed in to change notification settings - Fork 9
BaseAffix.push should push substacks too! #61
Description
The current implementation of BaseAffix has the push method insert an Affix object in a stack (thereby pushing down the Affix objects below it one slot further). This is done by modifying the pushing Affix component's and the inserted one's next_affix references so that
- the pushing Affix component's points at the new Affix object to be inserted, and
- the inserted one's points to where the pushing Affix pointed at previously,
like inserting an element in a single-linked list. See https://github.com/SeattleTestbed/affix/blob/master/components/baseaffix.r2py#L175-L180.
I think that the push method should also be able to push Affix stacks, i.e. components with already set-up interlinking. Apart from potential race conditions, you could implement similar functionality by parsing the desired Affix stack string manually and pushing multiple times, but why reimplement functionality that already exists? affix_stack has a build_stack method for the first part, and BaseAffix.push can be amended to set the correct references (the current Affix's, and the new stack's bottommost) by adding a bit of stack inspection.
(I'll add a practical example where this is really useful in a bit.)