Re: [Vala] use weak and var together
- From: Yu Feng <rainwoodman gmail com>
- To: Jürg Billeter <j bitron ch>
- Cc: vala-list gnome org
- Subject: Re: [Vala] use weak and var together
- Date: Sat, 10 Jan 2009 01:04:47 -0500
Hi Jurg,
Sorry for digging such an old post but I discovered something. See the
end of the message.
On Fri, 2008-12-12 at 08:08 +0100, Jürg Billeter wrote:
On Thu, 2008-12-11 at 23:56 -0500, Yu Feng wrote:
On Thu, 2008-12-11 at 22:11 +0100, Jürg Billeter wrote:
On Wed, 2008-12-03 at 14:05 +0000, Frédéric Gaudy wrote:
I don't know if it' a bug or a feature. When I use weak and var
keywords, I obtain a error:
error: The type name `var' could not be found
Code :
weak var thread = Thread.create( this.process_thread, true);
I haven't decided yet whether we should support that and if yes, what
exact syntax to use. In addition to your example, just
weak thread =...
might also be a possibility. I tend to not support it at all at the
moment and rather try to minimize the number of situations where 'weak'
is needed.
I am wondering why you dislike weak so much. It does usually mess stuff
up but it is also good if one knows what she is doing.
It not only saves a ref and unref, but also breaks circular references.
var is only used for local variables and you never need to break
circular references with local variables. I only dislike it if it's used
to workaround issues with not reference-counted objects. weak is
perfectly fine to break circular references, that's the main reason it
exists.
Talking about circular references, is it possible to have a circular ref
breaker mechanism like the one in GTK for vala fundamental classes?
I don't think we should always add a dispose mechanism to fundamental
classes. However, if someone wants to use that, it should still be
possible to implement this with a bit of extra Vala code.
I suddenly realized it is impossible to write dispose mechanism with
extra vala code because one can not override the hidden unref method,
therefore one can not do the cycle detection/breaking at the right time.
Yu
Jürg
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]