Re: [Vala] Should be warning(maybe error) when method with [ReturnsModifiedPointer] is called from unowned variable



I am confused here. What [ReturnsModifiedPointer] has to do with
copying/referencing an object?

With GLib.SList list = given_list; you do not create a copy of an object
but owned reference/pointer. And if you do anything to that reference, you
will modify given_list too.

And in most cases not copying object, but referencing it is desired
behaviour, so I don't see problem here. I would also not desire assuming
that copy should be created whenever I assign object from unowned reference
to owned reference.

I think that everything is ok here, unless I am missing something.

Could you describe the result you expect from the code you provided?

Jarek

2012/11/4 Tal Hadad <tal_hd hotmail com>


There should be warning(maybe error) when method with
[ReturnsModifiedPointer] is called from unowned variable.

Take a look on GLib.SList. The beginner programer(me too) can be
assign an unowned variable to the list, and remove items, but he
don't know it shell update the owned pointer.

Example:

GLib.SList list = given_list;
list.remove(data);

Naive programers can be fooled(like me) that this code are valid,
since Vala print no errors neither warning.

I think we all agree it's NOT ok, but do you see this as error or warning?

Yours
Tal

_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list




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