[fpc-devel] Parameters must match exactly?
nc-gaertnma at netcologne.de
Mon May 17 11:47:08 CEST 2010
On Mon, 17 May 2010 10:40:12 +0100
Martin <fpc at mfriebe.de> wrote:
> On 17/05/2010 10:29, Mattias Gaertner wrote:
> > Theoretically: yes, this could work for classes.
> > But as Jonas explained a few times: 'out' is *not* write only.
> > Out is finalised and must therefore match exactly.
> > And even write-only is not enough for "object"s because an ancestor
> > has too less memory.
> Hm, finalization isn't happening in the user code. So shouldn't be an
> issue... and:
> - are class-instance finalized? (maybe with interfaces)
> - it's an implementation detail of the compiler => it could (maybe does)
> happen, in the calling code (where type info is known)
> memory is allocated on the heap
> s and x are both just pointers => so the size matches
> Actually x is a pointer to s, and s a pointer to the memory. but s can
> be changed, so the memory can be re-allocted.
No, for example:
TAncestor = object
TMyObject = object(TAncestor)
j: string; // need more mem
procedure Doh(out o: TMyObject);
o.j:='3'; // writing beyond
o: TAncestor; // limited mem
More information about the fpc-devel