[fpc-pascal]self

Ingmar Tulva juss_it at ut.ee
Wed Oct 23 12:09:56 CEST 2002


One thing is unclear to me:

type
  t1 = object
    procedure p(var s:t1);
  end;

  t2 = object(t1)
    {some fields here}
  end;

procedure t1.p (var s:t1); { or "const" or ^t1 }
 begin
   Self:=s;
 end;

var
  o1,o2 : t2;

begin
  ---
  o1.p(o2);
  ---
end.

Will the additional fields of t2 be assigned or not? If not, then what is
the use of this feature (assigning something to Self)? Otherwise, what if
the declarations were:

var o1:t1; o2:t2;

or:

var o1:t2; o2:t1;

Not only ugly but confusing :-)

------

Ingmar Tulva





More information about the fpc-pascal mailing list