[fpc-pascal]self

Adam Naumowicz adamn at math.uwb.edu.pl
Wed Oct 23 15:46:35 CEST 2002


On Wed, 23 Oct 2002, Jonas Maebe wrote:

> I don't think the above will even compile, because var parameters must
> match exactly. Anyway, the extra fields cannot be assigned, because
> they don't exist in t1 (so there is no memory available to put them in).
>
> > If not, then what is
> > the use of this feature (assigning something to Self)?
>
> You can replace the values of all the fields of an object with those of
> another object inside a method (this is important, because when you're
> outside a method, you can simply assign one object to another) without
> having to type all the fields explicitely.

Exactly, it's useful when you want to copy a whole object at a time + VMT.
As it used to be a 100% valid Pascal expression for some twenty years, my
original question was why it was forbiden in FPC 1.1. Can it be restored
(for the sake of Borland compatibility for instance) ?

Adam Naumowicz

======================================================================
Department of Applied Logic            fax. +48 (85) 745-7662
Institute of Computer Science          tel. +48 (85) 745-7559 (office)
University of Bialystok                e-mail: adamn at mizar.org
Sosnowa 64, 15-887 Bialystok, Poland   http://math.uwb.edu.pl/~adamn/
======================================================================






More information about the fpc-pascal mailing list