The iterator interface



The Python language binding discussion with James stumbled on an
interesting point of discussion:

GObject* tny_iterator_iface_next (TnyIteratorIface *self);
GObject* tny_iterator_iface_prev (TnyIteratorIface *self);
GObject* tny_iterator_iface_first (TnyIteratorIface *self);
GObject* tny_iterator_iface_nth (TnyIteratorIface *self, guint nth);
GObject* tny_iterator_iface_current (TnyIteratorIface *self);


Shouldn't these methods add a reference to the returned object? If while
iterating a list gets modified (for example an item gets removed) and
the current item is the one that was modified (removed), the current
would other possibly be destroyed.

This would only happen in a multi-threaded situation, of course.

I was thinking about not letting the first four return the GObject, and
letting _current add a reference. What do you guys think?


-- 
Philip Van Hoof, software developer at x-tend 
home: me at pvanhoof dot be 
gnome: pvanhoof at gnome dot org 
work: vanhoof at x-tend dot be 
http://www.pvanhoof.be - http://www.x-tend.be




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]