[fpc-devel] Parameters must match exactly?
Jonas Maebe
jonas.maebe at elis.ugent.be
Tue May 18 16:07:11 CEST 2010
On 18 May 2010, at 15:25, Vinzent Höfler wrote:
> But that wasn't the problem. The problem I mean is that:
>
> procedure p (out c : tc2)
> begin
> c := tc3.create;
> end;
>
> var
> c1 : tc1;
>
> begin
> p(c1);
> end.
>
> seems not to be allowed anymore.
I guess you mean tc2.create instead of tc3.create. You're correct that
this is no longer accepted by FPC (nor is it accepted by Kylix). And
if you don't abuse "out" parameters as "var" parameters (although I'm
quite sure there's plenty of code out there that does this -- we've
also had issues with that in the compiler source itself), I also do
not immediately see how the above could be dangerous. Then again, for
some 10 or more years nobody thought of how the old behaviour allowed
subverting the complete type checking model of the compiler either
(which is why "useless restriction from Delphi" probably wasn't
implemented initially).
> BTW, I still can not follow the argument of that "out" parameters
> need finalization.
It does not apply in the case of classes. Finalisation is only
inserted, at the caller side (hence, where the exact type is known),
in case of reference counted types.
Jonas
More information about the fpc-devel
mailing list