On 17/05/2010 10:47, Mattias Gaertner wrote:
On Mon, 17 May 2010 10:40:12 +0100
Martin<f...@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:
I quite clearly wrote "class-instance"
I am aware it doesn't work for object.
type
TAncestor = object
i: string;
end;
TMyObject = object(TAncestor)
j: string; // need more mem
end;
procedure Doh(out o: TMyObject);
begin
o.j:='3'; // writing beyond
end;
procedure A;
var
o: TAncestor; // limited mem
begin
Doh(o);
end;
Mattias
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel