Re: [Vala] Change in 0.23.1 for array ownership and .length parameter
- From: Luca Bruno <lethalman88 gmail com>
- To: Tal Hadad <tal_hd hotmail com>
- Cc: Vala Mail List <vala-list gnome org>
- Subject: Re: [Vala] Change in 0.23.1 for array ownership and .length parameter
- Date: Thu, 9 Jan 2014 22:10:38 +0100
On Thu, Jan 9, 2014 at 9:58 PM, Tal Hadad <tal_hd 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 variables - one for owned and one for
unowned.
The owned always deleted at the end of the block, the trick is that this C
variable is
set to null when transferring ownership.
If an owned "bar" was defined outside the block, I already said you're
right and it
should be null in when outside the block(e.g. class field), since there's
no way to
automate this safely.
I know it may add a minor complicity, but it just seems rational to use an
object with
"unowned" access after transferring it to something else, since passing
ownership
privilege doesn't means forgetting a reference.
Ok now this makes sense, but it's not worth in my opinion. I've never
encountered such a use case personally.
I suppose that most Vala programmer solve this(including me) problem by
saving
this variable in different unowned variable, but this is not
intuitive(especially for a
new language) and may raise many bugs.
I don't think so, I never had such a use case.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]