> Yes, now I see it. I guess that it might be error specific to implementation 
> of GLib.SList.No it's not. GLib implicated it as the way they see this, and 
> Vala coordinate it with [ReturnsModifiedPointer].
> I won't be able to help you :( (btw, I use Gee for lists/arrays etc).It's not 
> a matter of help. I just wish that there will be error when developer call a 
> method with [ReturnsModifiedPointer] (i.e. SList.remove ()) from unowned 
> variable, or at least a warning. That will fix the whole this.Also, I admire 
> Gee work, but in term of performance for internal lists, I guess most devs 
> will chose SList
Would you chose to warn/err the developer when this situation invoked?Should I 
open a bug report?
Tal
Date: Thu, 8 Nov 2012 01:12:10 +0100
Subject: Re: [Vala] Should be warning(maybe error) when method with 
[ReturnsModifiedPointer] is called from unowned variable
From: [email protected]
To: [email protected]
CC: [email protected]

Yes, now I see it. I guess that it might be error specific to implementation of 
GLib.SList.
In example that you gave, same behaviour can be seen when removing first item 
from other list (given_list). If it is first item, list you were modifying 
works fine, but other seems to be broken (it is the same in both cases, 
modifying given_list or list).

I won't be able to help you :( (btw, I use Gee for lists/arrays etc).
Jarek
2012/11/6 Tal Hadad <[email protected]>



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: [email protected]

To: [email protected]

CC: [email protected]



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 <[email protected]>







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



[email protected]



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







                                          
_______________________________________________

vala-list mailing list

[email protected]

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



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

Reply via email to