"Andrés G. Aragoneses" píše v Čt 21. 01. 2010 v 03:17 +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]. >
Ah, yeah. My statement a bit wrong. Of course you should use it where appropriate, but remember what the meaning is now and what it will be in the future, so it doesn't surprise you when the change comes. Also note that the keyword is still being misused a lot in current code (in places where 'unowned' should be), that's why I suggested you shouldn't use it yet - with the proper understanding of the problems involved you can freely ignore my advice. > > > 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? > > Yes, indeed it would work the same. Although 'weak' local variable is not very useful (except perhaps in asynchronous methods or closures). > 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). > > _______________________________________________ > Vala-list mailing list > [email protected] > http://mail.gnome.org/mailman/listinfo/vala-list
signature.asc
Description: Toto je digitálně podepsaná část zprávy
_______________________________________________ Vala-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/vala-list
