From an internal XSUB, and given an HV*, I'd like to iterate
over the whole array and deal with (key, value) pairs.
The trouble is I can't seem to be able to call hv_iternext()
like pp_each() does because there is no local iterator state
that enables me to save the previous iterator, do my own
iteration, then resume control to the previous iterator.
So if I call hv_iternext() from my XSUB, and the user calls my XSUB
from an each loop on the same HV, results will be scrambled. The
trouble is the user has no way to know I'm going to traverse that
HV in some way.
Could we add a routine to the perl internals to save the state
of any pending iteration on the HV, and then later on restore that
state. Meanwhile, the XSUB writer can do hv_iternext().
BTW, how do you know you have looped over the hash with hv_iternext?
Does it return 0?
Thanks.
Raphael
over the whole array and deal with (key, value) pairs.
The trouble is I can't seem to be able to call hv_iternext()
like pp_each() does because there is no local iterator state
that enables me to save the previous iterator, do my own
iteration, then resume control to the previous iterator.
So if I call hv_iternext() from my XSUB, and the user calls my XSUB
from an each loop on the same HV, results will be scrambled. The
trouble is the user has no way to know I'm going to traverse that
HV in some way.
Could we add a routine to the perl internals to save the state
of any pending iteration on the HV, and then later on restore that
state. Meanwhile, the XSUB writer can do hv_iternext().
BTW, how do you know you have looped over the hash with hv_iternext?
Does it return 0?
Thanks.
Raphael