Re: [Vala] Change in 0.23.1 for array ownership and .length parameter

2014-01-11 Thread Maciej Piechotka
On Thu, 2014-01-09 at 22:10 +0100, Luca Bruno wrote: On Thu, Jan 9, 2014 at 9:58 PM, Tal Hadad tal_hd-pkbjnfxxiarbdgjk7y7...@public.gmane.org wrote: That would be a memory leak. No it wouldn't: If the if statement is false, then it should delete it in the end of the block. You

Re: [Vala] Change in 0.23.1 for array ownership and .length parameter

2014-01-09 Thread Luca Bruno
That would be a memory leak. On Thu, Jan 9, 2014 at 7:01 PM, Tal Hadad tal...@hotmail.com wrote: What about: if (foo) { bar = (owned) ar; } // what now This behavior is confusing. It would be unowned, even if in if statement, just like I suggest. Tal Date: Tue, 7 Jan

Re: [Vala] Change in 0.23.1 for array ownership and .length parameter

2014-01-09 Thread Tal Hadad
That would be a memory leak. No it wouldn't: If the if statement is false, then it should delete it in the end of the block. You might afraid the complicity of valac calculation. That could be resolved - using two C variables - one for owned and one for unowned. The owned always deleted at the

Re: [Vala] Change in 0.23.1 for array ownership and .length parameter

2014-01-09 Thread Luca Bruno
On Thu, Jan 9, 2014 at 9:58 PM, Tal Hadad tal...@hotmail.com wrote: That would be a memory leak. No it wouldn't: If the if statement is false, then it should delete it in the end of the block. You might afraid the complicity of valac calculation. That could be resolved - using two C

Re: [Vala] Change in 0.23.1 for array ownership and .length parameter

2014-01-07 Thread Jürg Billeter
Hi Tal, On Tue, 2014-01-07 at 07:46 +0200, Tal Hadad wrote: The user might use ar varible later and it will crush he's application. If he was lucky enough, he would realize that ar is null. It's not easy to find that this line causing it. Risking dangling pointers is much worse than null

Re: [Vala] Change in 0.23.1 for array ownership and .length parameter

2014-01-07 Thread Luca Bruno
On 07/01/2014 06:46, Tal Hadad wrote: This case trigger me a question I wanted to ask before. Why transforming ownership is nulling the original variable? Instead of nulling, maybe just change variable to behave as unowned. You might say that there is a problem in my solution, like this code:

[Vala] Change in 0.23.1 for array ownership and .length parameter

2014-01-06 Thread Jim Nelson
Just wanted to give everyone a head's-up about a change that appeared in Vala 0.23. Previously you could do this in Vala: uint8[] ar = new uint8[10]; // ... fill ar with interesting bytes ... process((owned) ar, ar.length); ... where process() takes an array and a length field (sometimes

Re: [Vala] Change in 0.23.1 for array ownership and .length parameter

2014-01-06 Thread Tal Hadad
This case trigger me a question I wanted to ask before. Why transforming ownership is nulling the original variable? Instead of nulling, maybe just change variable to behave as unowned. You might say that there is a problem in my solution, like this code: uint8[] ar = new uint8[10]; if