I think what diotalevi is trying to acheive is the reverse of B's next method
Er, no. Siblings and next are two different things. Siblings
are a chain of ops at the same level in a tree; next is the next op
in execution sequence. For example
$ perl584 -MO=Concise -e'print "a", $b+1;'
9 <@> leave[1 ref] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 1 -e:1) v ->3
8 <@> print vK ->9
3 <0> pushmark s ->4
4 <$> const(PV "a") s ->5
7 <2> add[t1] sK/2 ->8
- <1> ex-rv2sv sK/1 ->6
5 <$> gvsv(*b) s ->6
6 <$> const(IV 1) s ->7
$ perl584 -MO=Concise,-exec -e'print "a", $b+1;'
1 <0> enter
2 <;> nextstate(main 1 -e:1) v
3 <0> pushmark s
4 <$> const(PV "a") s
5 <$> gvsv(*b) s
6 <$> const(IV 1) s
7 <2> add[t1] sK/2
8 <@> print vK
9 <@> leave[1 ref] vKP/REFC
Here, the first child of print is pushmark, and const and add are the two siblings of pushmark. On the other hand,
print's next op is leave.
Internally Perl doesn't store pointers to previous siblings,
not does it store a pointer to the parent. So my initial
reaction is that the OP's approach is correct. However, since
the B modules provide a parent() method when internally there is no such pointer, it's posssible that B:;* can do other clever stuff too. I've never looked at it myself.
Dave. |