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


Jonas
_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to