It is not possible. The only way would be to make a base class with and abstract clone method, and make all your app object derive from this base class. take in consideration that you will have to implement the clone method for every type you create, and you will have to deal with pointers to other classes.
The most problematic part of all this is how you clone this:
Type A Extends Clonable
Field MyField:OtherType
Method Clone()
.
.
.
End MeThod
End Type
Type OtherType Extends Clonable
Field Whatever:A
Method Clone()
.
.
.
End MeThod
End Type
Local MyVariable:A = New A
A.MyField = New OtherType
A.MyField.Whatever = A
Local MyOtherVariable:A = MyVariable.Clone()
The main problem here is how to clone Type A, as one of its fields points to another type instance. Should this be cloned too? if it is cloned, you could enter a infinite loop and make memory needs grow unpredictabily. If it is not cloned, you have only a partial 'copy' of the original object, so you will have to know what fields of your class are really cloned and what others are not. Not a real solution, and most important, not an 'automatic' solution.
|