[fpc-devel] Parameters must match exactly?

Alexander Klenin klenin at gmail.com
Thu May 20 14:18:38 CEST 2010

On Thu, May 20, 2010 at 23:03, Jonas Maebe <jonas.maebe at elis.ugent.be> wrote:
> 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.

Yes, sorry.

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

That would be good too.

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

I see no problem if this check is controlled by a compiler flag,
similar to R+, O+ etc, "on" by default.
Thinking about it, I like the idea very much -- it gives a way out
to those who are concerned with extreme speed, and those
whose code will be broken (although breakage with suggested
implementation will in 99% of cases mean a real bug,
as contrasted to the current implementation, when in 99% of cases
the correctly working code is broken).

Alexander S. Klenin

More information about the fpc-devel mailing list