On Fri, 2008-11-21 at 21:03 +0100, Jürg Billeter wrote:
> On Fri, 2008-11-21 at 02:59 -0500, Yu Feng wrote:
> > On Wed, 2008-11-19 at 18:26 -0500, Yu Feng wrote:
> > > When the collections in Gee are holding strong references, it is
> > > difficult to obtain a weak reference to the elements in the container.
> > > 
> > > The situation is:
> > > 
> > > class Node {
> > >   Gee.List<Node> childNodes;
> > >   public Node? firstChild {
> > >           get {
> > >                   return childNodes.get(0);
> > > ////// panic! the signature of properties are weak!.
> > >           }
> > >   }
> > > 
> > > }
> > 
> > A better alternative is to modify the signature of 'get' directly to
> > weak.
> 
> I understand your issue but I don't think that we should change the
> return value of `get' to weak as this would make it impossible to
> generate values in an iterator, for example.

Besides, a container is not a prototype-factory. A factory returns
strong references because the objects are cloned or referred. A
container should always return a weak reference because we want the
object in the container instead of a clone of the object.

Yu
> 
> An alternative is to default property getters to non-weak, this would
> also solve similar issues in other situations. Any objections?
> 
> Jürg
> 

_______________________________________________
Vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to