Re: [Vala] Ownership syntax changes



On Fri, 2008-12-19 at 12:10 +0100, Jürg Billeter wrote:

      * `(owned)' cast replaces `#' reference transfer expression

Even less used, equally unintuitive. Example of new syntax:

string foo = (owned) bar;

I don't have a strong opinion on this since I don't really need it, but
using a cast expression feels a bit wrong. Not sure if we want to keep
the option open of having operator overloading, but what about something
like:

string foo <= bar;
or
string foo << bar;


      * `unowned' type modifier complements `weak' type modifier

`weak' only make sense for reference fields, list elements, and local
variables to break reference cycles. Vala will use
`g_object_add_weak_pointer' in these places in future versions.

I definitely agree we should avoid dangling pointers as much as
possible. However, I fear a bit that many people will turn to using
pointers when this is also applied to local variables.

In other places where `weak' is currently used such as method return
values or fields of non reference counted types, it has the meaning of
"no ownership transfer". This is mostly used in bindings but can also be
used in Vala code to fine-tune the ABI. In my opinion, `unowned' as
counterpart to `owned' fits better in those places.

It probably depends how you look at it. Personally, I tend to think in
terms of shared and weak references. Owned and unowned seem to suggest
an object can only be owned in one place.

Hans




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]