[fpc-devel] Parameters must match exactly?

Jonas Maebe jonas.maebe at elis.ugent.be
Thu May 20 14:03:58 CEST 2010

On 20 May 2010, at 13:57, Alexander Klenin wrote:

> the safe version would be
> var tmp: TFPCanvasHelper;
> ...
> InitHelper(tmp, TFont);
> tmp := FFont as TFont;

I guess you mean "FFont := tmp as TFont" here.

> I suggest that compiler should generate the code equivalent to
> the third version based on the source from the first.
> This would be backwards compatible, and a strict improvement
> over 2.4.0 behavior.

It would not be backwards compatible, because if InitHelper or a  
function it calls also uses FFont, it will still see the old value  
instead of the value assigned to the "out" parameter. The code would  
have to be translated into something like this:

InitHelper(TFPCanvasHelper(FFont), TFont);
FFont := TFPCanvasHelper(FFont) as TFont;

However, having the compiler implicitly start inserting  
transformations like that behind the back of the programmer is not a  
nice principle either (except possibly if something like -CR is used).


More information about the fpc-devel mailing list