[Vala] Ownership syntax changes

I just committed some ownership syntax changes to trunk. The old syntax
will continue to be supported but is planned to be deprecated after the
release of Vala 0.5.4.

      * `owned' type modifier replaces `#' type modifier

This is not often used, but `#' was very unintuitive as a type modifier,
and I therefore decided to replace it by the hopefully better
understandable `owned' modifier. Example of new syntax:

public void foo (owned string bar) {

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

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

string foo = (owned) 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.

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.

Are there any questions or comments to these changes?


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