Re: [Vala] 'weak' keyword context?
- From: "Andrés G. Aragoneses" <knocte gmail com>
- To: vala-list gnome org
- Subject: Re: [Vala] 'weak' keyword context?
- Date: Thu, 21 Jan 2010 03:17:04 +0100
El 21/01/10 03:05, Jiří Zárevúcky escribió:
"Andrés G. Aragoneses" píše v Čt 21. 01. 2010 v 02:57 +0100:
Hi there,
My question is simple: can the "weak" keyword be used for local
variables instead of fields? (Sorry I cannot check it right now with the
last version.) If yes (or if it will in some future version), does it
really have any sense? Can I see an example?
Thanks,
Andrés
Hi Andrés,
in case I didn't oversleep, 'weak' keyword still doesn't have it's
intended semantics. You shouldn't use it (yet), because it's meaning
will change in the future. 'unowned' should be used instead (at the
That's not what it is said here [0].
moment the two are the same). But to your question: you can use it for
both fields and local variables.
Then, can you put a similar example as the one mentioned here [0] but
using local variables?
Thanks,
Andrés
[0] http://live.gnome.org/Vala/ReferenceHandling
In the future, 'unowned' will stay as
it is now, but 'weak' will keep track of the object you are referencing
with it, setting itself to null when it's destroyed.
Whether it makes sense for local variables depends on what you're trying
to achieve. Mostly it's irrelevant for the programs function, but
'unowned' can be used as a mean of performance optimization (only use
when you really know what you're doing).
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]