Re: [Vala] [Genie] instance creation order
- From: Arc Riley <arcriley gmail com>
- To: jamie mccrack gmail com
- Cc: vala-list <vala-list gnome org>
- Subject: Re: [Vala] [Genie] instance creation order
- Date: Wed, 6 Jan 2010 16:56:49 -0500
I know a lot of people don't approach docs as "language lawyers", but it'd
be helpful to improve the docs to state this. At present it reads (to me)
that it's improper to call any functions or perform any action at all
besides setting local properties in construct blocks.
So if I understand this correctly, if bar inherits foo, creating a new
instance of bar runs foo.init, bar.init, then bar.construct ?
On Wed, Jan 6, 2010 at 9:33 AM, Jamie McCracken <
jamie mccrack googlemail com> wrote:
so add any initilization code to the "set" part of any construction
property - this is a gobject foible IIRC
On Wed, 2010-01-06 at 09:30 -0500, Jamie McCracken wrote:
construct block should be used for setting property values
init is called before all constructors so is shared by them all
On Wed, 2010-01-06 at 02:17 -0500, Arc Riley wrote:
Why does a class's init method get called before its construct method?
This seems very counter-intuitive to me given the limitations on the
construct method;
A *construct* block is used to define a creation method which requires
parameters at construction time when being instantiated via the new
operator. Creation methods are limited to setting the properties of the
class and may perform no other task (an init block should be used to
perform
any other type of initialization). A class can have many creation
methods
with either different names or different parameters. A default creation
method without any parameters is always available if no explicit
creation
method is defined.
Since init runs first, none of the initialization code has access to
parameters passed to it by the new function. Say, for example, an
argument
passed is a parent container for the new instance to add itself to -
all the
construct method is allowed to do (if I read this correctly) is set
self._parent which only happens after init has run.
Am I reading this wrong, or do we need to implement some hacked up
delayed
initializer for the mainloop to handle to work around this?
_______________________________________________
Vala-list mailing list
Vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]