Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changes from Version 1 of class_init

Show
Ignore:
Author:
keinfarbton (IP: 217.228.165.88)
Timestamp:
10/20/06 10:21:44 (18 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • class_init

    v0 v1  
     1= Refactoring of field initializers, instance initializers and static constructors = 
     2 
     3 # In Java a class can have multiple instance initializers and class initializers. In D there are no instance initializer and only one static ctor is allowed. 
     4 # In Java a field can be initialized in its declaration. The initialization can also include nearly every expression. In D an initializer must be a compile time module-local constant value. 
     5 
     6== Static ctors and initialization of static fields == 
     7If a static field initializer or a static initializer exists, TioPort generates a new static ctor, replacing the originals. 
     8This new static ctor contains all static field initializations and code of all static initializers. Every piece of code is placed in its own statement list. 
     9 
     10== Instance initializers and initialization of instance fields == 
     11If a non static field initializer of a instance initializer exist, TioPort generates a private method called "GENERATED_INSTANCE_INIT". All initializers and instance init code is moved into this method. Every piece of code is placed in its own statement list. 
     12 
     13After this step all ctors are searched. If the ctor does not have a call to another ctor of this class ( called "this" ), a call to the init method is inserted at the beginning of the ctor. 
     14