[Lazarus] Form events firing order and count

Michael Van Canneyt michael at freepascal.org
Mon Feb 19 19:47:14 CET 2018



On Mon, 19 Feb 2018, Martok via Lazarus wrote:

> Am 19.02.2018 um 11:10 schrieb Sven Barth via Lazarus:
>> As long as the code does not rely on undocumented behavior, yes. 
> And therein lies the issue. Things that worked the same way for >25 years and
> are mentioned explicitly in numerous secondary literature are considered
> "undocumented".

I will mention 1 case in point. Const parameters.

For years, people mistakenly assumed that Const parameters were 
be passed by reference if they were "big" (records), a behaviour which
Delphi exhibited. And 'mentioned explicitly in numberous secundary
literature' as you put it so nicely. But not documented.

FPC introduced Constref to guarantee a constant was passed by
reference (I think IUnknown methods were the first to use this), 
but otherwise refused to change our view of 'Const'.

Then one day, someone on the Delphi team (I believe Allan Bauer?) makes a
blog post stating that "Const never implied that big types are passed by
reference", and that people should correct their code and use the new [Ref]
attribute if they want a const parameter passed by reference.

Thus supporting the point of view which we had all along.

So, no, we will not promise to conform to undocumented behaviour.

And documented behaviour is what the language guide of Delphi states.

So unless Delphi _documents_ that

MyClass.SomeInterfaceExpression.SomeMethod;

is 100% equivalent to

Temp:=MyClass.SomeInterfaceExpression;
try
   Temp.SomeMethod;
finally
   Temp:=Nil;
end;

It remains an implementation detail when the temp is finalized.

Which, in FPC, is currently at the end of the procedure.

Michael.


More information about the Lazarus mailing list