Skybuck Flying schrieb:
Hello,

I want to write code as follows and I will simplify it here to illustrate
the problem.

Let's say I want to kinds of records: TrecordA and TrecordB.

I want to be able to convert types of TrecordA to TrecordB but I also want
to be able to convert types of TrecordB to TrecordA.

So I was thinking of writing code as follows:

type
   TrecordA = record
       function ToRecordB : TrecordB;
   end;

   TrecordB = record
       function ToRecordA : TrecordA;
   end;

That's the wrong way. You should pass in an parameter of the output type, allocated by the caller. Then pass it as a pointer, and declare the pointer types before the records.

DoDi

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to