But while I was trying to confirm this in libxml, I found behaviour that makes me think there's some more fundamental bug. Redefining a variable seemed to have some very odd effects, which I managed to reduce to this case:
(That's the existing definition of #<<, not your extension)
Exiting from the irb session results in a segmentation fault, and running the same code outside of irb yields the same apparent results (inclusion of 'b' where it shouldn't be), and resulted in a bus error. I have the hunch that the C extension isn't managing memory properly, which is confirmed by one of the errors submitted on the project page. Maybe this is just my setup (1.8.4 on OSX), but it seems to me that the library has enough problems that it's not quite ready for use.
matthew smillie.
···
On Jul 8, 2006, at 2:37, transfire@gmail.com wrote:
hi,
While using #each to loop thru the children of a Node, if I remove a
node the loop breaks on it's own.
It's usually a problem to change a container while iterating through
it. This can generate all sorts of weird effects. It's generally
better to rely on this *not* being possible unless explicitely stated
(e.g most of Java's iterators implement remove() which savely removes
an element while iterating).
In your case I'd either first remove the one you want to get rid of,
iterate using an index (if that's possible) or remember objects to
remove in some kind of container and do the removal after the
iteration (probably the most efficient solution).
But while I was trying to confirm this in libxml, I found behaviour
that makes me think there's some more fundamental bug. Redefining a
variable seemed to have some very odd effects, which I managed to
reduce to this case:
[snip]
=> <root>
<a/>
<b/> # where did *this* come from?
</root>
(That's the existing definition of #<<, not your extension)
Exiting from the irb session results in a segmentation fault, and
running the same code outside of irb yields the same apparent results
(inclusion of 'b' where it shouldn't be), and resulted in a bus
error. I have the hunch that the C extension isn't managing memory
properly, which is confirmed by one of the errors submitted on the
project page. Maybe this is just my setup (1.8.4 on OSX), but it
seems to me that the library has enough problems that it's not quite
ready for use.
Thanks matthew. Very enlightening. I decdided to write a xml wrapper
and create an common interface for either REXML and libxml. That way I
can use REXML for now and easy switch over when libxml binding are
fully operational.