Re: [Vala] private fields vs bodyless properties



On Fri, May 30, 2008 at 2:05 AM, Hans Vercammen <hveso3 gmail com> wrote:
Now the construct keyword for properties in the class constructor
arguments is being deprecated, I started to adjust some things and
stumbled upon some implementation questions.

While "private int foo { get; set; }" does not make much sense and
should better be optimized to "private int foo;", assignment of the
private field foo in the constructor with a constructor argument is not
possible at the moment, only property assignments are allowed. There
might be a good reason for this, but I could not find any reference, so
just a quick question here.

The reason for this is that the objects are gobjects and these are
created by a g_object_new call [1]. That function can only set
properties. So you need to have a property if you want to pass data to
your constructor

Jaap

[1] http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#g-object-new



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