On Sa, 2014-12-27 at 19:56 +0200, Chriss Kalogeropoulos wrote:
> Hi,
> 
> FPC does not support copy-construction so either you must override the
> TPersistent.Assign method or in case of TComponent you can use
> ReadComponent/WriteComponent.

:|

> You should also take into account deep vs swallow copy semantics as well as
> the type of the container and contained classes
> (TPersistent/TCmponent/TCollection descendant).

TCollection is a good idea. Life could be easier if all data container
classes would keep their properties in a name/value hash.

You're right, looking at the implementation of TPersistent and
TComponent and comparing the overhead to simple data classes is on my
list.

And of course I'm aware of the shallow copy vs. deep copy problem.

> For records I am not sure, probably you should need a method on the
> container or check on some internal (compiler magic) functions such as
> CopyRecord and others.

Currently I'm dealing with records, so there is my first target.

I feared it would be that way. I think writing an extension for Lazarus
and linking it into the "source" or "refactoring" menu will be a lot
less work, I'll have a deeper look.

> Hope that helps.

It does, thank you.

> Chriss
> On Dec 27, 2014 6:22 PM, "Marc Santhoff" <m.santh...@web.de> wrote:
> 
> > On Sa, 2014-12-27 at 16:45 +0100, Bart wrote:
> > > On 12/27/14, Marc Santhoff <m.santh...@web.de> wrote:
> > >
> > > > function clone(data_in: a_record): a_record;
> > > > var
> > > >   data: Pa_record;
> > > > begin
> > > >   new(data);
> > >      data^ := data_in;  //should work*
> > > > end;
> > >
> > > * Might not be a good idea if data contains a class(reference).
> >
> > Oops, I just typed that away and did not hit CTRL-F9 - which is useless
> > in the mailer anyway. ;)
> >
> > --
> > Marc Santhoff <m.santh...@web.de>
> >
> > _______________________________________________
> > fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
> >
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

-- 
Marc Santhoff <m.santh...@web.de>

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to