On Mon, Sep 23, 2013 at 4:28 PM, Zaher Dirkey <parm...@gmail.com> wrote:

> ​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.
> ​
> That's the feature I like to have. ​
>
> Best Regards


​This is a funny example about what in my mind about what I talk (I know it
is stupid and unsafe)
If you look it is only for the class that not yet inherited yet, and work
only for the top class, but the compiler can guss all inheited/derived
classes and make the same assign.
If some understand it, maybe give more explain.
​-----------------------------------------------------
type
  TmyRec = record
    s: string;
    i: integer;
  end;
  PmyRec=^TmyRec;

  TmyObj = class(TObject)
    s: string;
    i: integer;
  end;


procedure TForm1.Button1Click(Sender: TObject);
var
  o1, o2: TmyObj;
begin
  o1 := TmyObj.Create;
  o2 := TmyObj.Create;
  o1.s := 'test1';
  o1.i := 122;
  PmyRec(@o2)^ := PmyRec(@o1)^;
  WriteLn(o2.s);
  WriteLn(o2.i);
end;
​-----------------------------------------------------​

Best Regards
Zaher Dirkey
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to