> Yes. But that works only for 'simple' types and still requires you to write code.
> For the more general case where you can have arrays, classes, interfaces and whatnot as fields of your object, there is simply no correct way.
> Isn't there? Maybe it wouldn't be easy, but IIRC Delphi offers something related to this with TComponents and Streams. This Delphi mechanism I knew worked only for properties,
> but I found references that there existed a wider mechanism in D2010.
There is no GENERAL way.
The RTTI based mechanisms make special assumptions about how to reference components, tpersistents and whatnot.
If I have a field that is a stream. How are you going to correctly copy this ?
Just the stream instance pointer ? The stream+Contents ?
The answer depends on how the classes are supposed to behave. The language itself cannot give you this mechanism.
On Mon, Sep 23, 2013 at 12:58 PM, Graeme Geldenhuys <[hidden email]> wrote:
Also be careful about the pitfalls of cloning a class. eg: How you want to handle more complex cases. eg: Cloning a class with a reference to another class, or cloning a class with an embedded class (field), etc... tiOPF's implementation allows the developer to decided how such cases should be handled.
The idea is simply than needs to use a stream or RTTI, it is like a record, if looked at an object like as a record but it is inheritable.
Compile can now every object body, and do the assigning as record assign.