I'm sorry, the example I gave is bad. Forgot the "unowned" word.
Example:

unowned GLib.SList list = given_list;

list.remove(data);

Do you see the problem here?
If "data" is on the FIRST item on the list, it only removes it from
"list", not from the owned variable "given_list".

I run into bug likes that im my program and just wanted to warn
Vala devs.

Do you see the problem now?

Tal

Date: Mon, 5 Nov 2012 17:01:14 +0100
Subject: Re: [Vala] Should be warning(maybe error) when method with 
[ReturnsModifiedPointer] is called from unowned variable
From: kotow...@gmail.com
To: tal...@hotmail.com
CC: vala-list@gnome.org

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...@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



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

Reply via email to