[fpc-devel] Parameters must match exactly?
fpc at mfriebe.de
Mon May 17 11:05:27 CEST 2010
On 14/05/2010 15:52, Mattias Gaertner wrote:
> "var" means, you can do this:
> TQStrings = class(TStrings)
> procedure A(var s: TStrings);
> Then your TStringList will no longer be a TStringList. That's why 'var'
> must match exactly.
> Same for out.
> Const and no modifier allows to pass descendants.
yes, true, then if we follow that consequently:
procedure Foo(out s: TStrings);
var x: TObject;
should work? (or well only if it is made sure, that out really means
out, so the procedure is not allowed to use the value that was passed in)
"s" can be assigned a TStrings (or descendant of) => which should be
fine, since it can be stored in x too.
More information about the fpc-devel