Re: [Vala] Property getters and memory management
- From: Jürg Billeter <j bitron ch>
- To: Ali Sabil <ali sabil gmail com>
- Cc: vala-list gnome org
- Subject: Re: [Vala] Property getters and memory management
- Date: Sat, 10 Jan 2009 15:31:24 +0100
On Fri, 2008-12-19 at 17:22 +0100, Ali Sabil wrote:
On Fri, Dec 19, 2008 at 1:29 PM, Jürg Billeter <j bitron ch> wrote:
As mentioned in an other thread, I'm considering to change property
getters to transfer ownership by default. While the current behavior
works fine in many cases, in some cases it does not work at all and can
cause bugs in the resulting application or library.
Whenever you want to return a constructed - instead of stored - string
or object, the property getters need to transfer ownership, which is
only possible with an unintuitive syntax in Vala 0.5.3 and earlier.
As I understand that Vala libraries, that are used from C, might not
want to return an owned value from property getters in most cases, we
will certainly continue to support this without restrictions.
I am not entirely sure about the use of "owned" property getters, I
think the default should remain "unowned", not that it is better, but
to remain consistent with the established conventions in the C/GObject
world, and avoid confusion. Also, from my experience, the use of
"owned" properties is pretty limited. So the syntax I am proposing for
it is:
public string foo { owned get; set; }
What do you think about it?
I've decided to keep the defaults as they are to avoid ABI
inconsistencies, as property getters returning owned values should be
rarely needed. r2323 supports the above syntax. string# still works but
is now deprecated.
Jürg
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]