Re: [Vala] private fields vs bodyless properties



On Fri, 2008-05-30 at 10:40 +0200, Juerg Billeter wrote:
Assigning private or protected values during construction is a rather
common practice, but I don't know what the preferred solution would be.
Personally I like the {get; set;} thing, even for just marking private
fields read/write/construct only, but maybe some final optimization
layer in the generator should simplify this.

I generally recommend the following for construct-only properties:

public string foo { private get; construct; }

Vala should probably throw an error when trying to assign a private
non-construct property during construction, since private properties are
not registered as GObject properties.

Currently this works due to the non-construct optimization.

Hans




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