[fpc-devel] Parameters must match exactly?

"Vinzent Höfler" JeLlyFish.software at gmx.net
Tue May 18 20:21:00 CEST 2010

Florian Klaempfl <florian at freepascal.org>:

> 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?

And it is pretty obvious to me that the typecast would change the wrongness of the code.

> >> 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.

I assumed a tc1 -> tc2 -> tc3 inheritance, sorry if I missed something here. So creating an instance of tc3 and assigning it to a variable of tc2 should be legal.

> > end;
> > 
> > var
> >   c1 : tc1;
> > 
> > begin
> >   p(c1);
> > end.
> > 
> > seems not to be allowed anymore.
> Please test your examples first before doing some wild guesses.

I think it was Jonas who said it wouldn't be possible anymore. So it's far from being a wild guess, although I must admit that I haven't tried it for myself. Actually I never used FPC bleeding edge, so unless 2.6 comes out, I won't even notice the problem.

> > 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?

Well, Mattias Gärtner wrote:

"But as Jonas explained a few times: 'out' is *not* write only.
Out is finalised and must therefore match exactly."

I'm reading my mail on-line, so I apologize in advance excuse me if it's hard to me to find the correct mail with the precise wording. Maybe, Mattias can.


GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

More information about the fpc-devel mailing list