[fpc-devel] Parameters must match exactly?

Florian Klaempfl florian at freepascal.org
Tue May 18 15:43:28 CEST 2010


Vinzent Höfler schrieb:
>> 
>> was allowed and this code is simply broken, the compiler has to
>> complain and this was fixed.
> 
> Agreed. But in that case a function result of type tc1 wouldn't be
> allowed to be assigned to tc3 either. So your previous statement
> ("use a function instead") didn't make too much sense in this
> context, did it?

It is pretty obvious for me that one needs an as-operator in this case?
Using the as-operator with var parameters is however not possible
without a temp. variable.

> 
>> Code depending on this lazy behaviour simply needs to be fixed,
>> there are several solutions like inserting a explicit type cast or
>> using functions maybe together with the as operator.
> 
> 
> But that wasn't the problem. The problem I mean is that:
> 
> procedure p (out c : tc2)
> begin
>    c := tc3.create;

This breaks already here if I assume the type definitions I used.

> end;
> 
> var
>   c1 : tc1;
> 
> begin
>   p(c1);
> end.
> 
> 
> seems not to be allowed anymore.

Please test your examples first before doing some wild guesses. It is
useless to discuss about completly broken code.

> 
> BTW, I still can not follow the argument of that "out" parameters
> need finalization. Sure, for reference counted types this may be
> true, I won't argue that, but "out" used to work for integers as well
> as other types needing no finalization, so the compiler should not
> insert finalization code when classes are involved

Who said that this is done?



More information about the fpc-devel mailing list