I find it best not to use New(). I instead prefer a Create() function or method. It is a little more work, but you gain a lot more flexibility that way. For example:
You now can make an instance of any parent or extended type, and pass it parameters. The calling order is from base type to extended type. However, if you move the call to Super.Create() so it is right above the Return Self, then it will be called in extended to base order.
As a matter of fact, by changing where the Super.Create() is called, you can pretty much have the base types called in any order you want at any place in the initialization.
Edit: Just read your reply after I posted. The above method will require the same parameter types be passed to all extended classes, but since I am returning Object and then casting back to the appropriate type at the New command, you can extend this to handle any type.
SuperStrict Type A Field x:Int Method Create:Object(x:Int) Self.x = x + 10 Print "In Type A" Return Self End Method End Type Type B Extends A Field x:Int = 0 Method Create:Object(x:Int) Super.Create(x) Print "In type B" Return Self End Method End Type Type C Extends B Field x:Int Method Create:Object(x:Int) Super.Create(x) Self.x = x Print "In Type C" Return Self End Method End Type Local MyA:A = A(New A.Create(3)) Print "MyA.A = "+MyA.x Print Local MyB:B = B(New B.Create(7)) Print "~nMyB.A = " + A(MyB).x Print "MyB.B = " + MyB.x print Local MyC:C = C(New C.Create(10)) Print "~nMyC.A = "+A(MyC).x Print "MyC.B = "+B(MyC).x Print "MyC.C = "+MyC.x
You now can make an instance of any parent or extended type, and pass it parameters. The calling order is from base type to extended type. However, if you move the call to Super.Create() so it is right above the Return Self, then it will be called in extended to base order.
As a matter of fact, by changing where the Super.Create() is called, you can pretty much have the base types called in any order you want at any place in the initialization.
Edit: Just read your reply after I posted. The above method will require the same parameter types be passed to all extended classes, but since I am returning Object and then casting back to the appropriate type at the New command, you can extend this to handle any type.