Before the new version it was like you suggest but the developer saw things differently..
Still not making any sense to me.
This is apparently the function in current trunk (See ByteBites post)
function TCustomFormEditor.DescendFromDesignerBaseClass(AClass: TComponentClass): integer;
var
i: Integer;
begin
Result:=-1;
for i:=0 to FDesignerBaseClasses.Count-1 do
begin
if AClass.InheritsFrom(TClass(FDesignerBaseClasses[i])) then
begin
if (Result<0)
or (AClass.InheritsFrom(TClass(FDesignerBaseClasses[Result]))) then
Result:=i;
end;
end;
end;
For all intents and purposes let's say "FDesignerBaseClasses" has 12 Entries (From wherever those entries come from)
Result is "-1" from the get go
for i=0, 1, 2 Line 8 returns false (No Match), but on i = 3 there is a Match
Since Result is -1 at that point, left side of the "or" short-circuits (right side is ignored), and sets Result to 3
for i=4,5,6 there is no match again, but on i=7 there is a match
Since Result is now >0 (from iteration i=3) right side of the "or" gets executed, but it checks if there is a match for "Result" (which is "3" in our example) as Index of the List.
WHICH HAS ALREADY BEEN ESTABLISHED AS TRUE on the fourth iteration (i=3), and sets the Result to the "current" i (which is "7").
Irrespective of any intermediary Results: The Function returns the highest Index with a Match (Or -1 if no match at all).
Where is the difference to my Proposal or the Code in Lazarus 3.8?