Ordre de résolution des paramètres
Bonjour,
Lorsque je crée un TPoint à l'aide de Point(mafonction(), mafonction()),
le premier appel a mafonction() est réalisé pour le second parametre.
et le second appel pour le premier paramètre.
code de test
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| unit testunit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs;
type
{ TForm1 }
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
index : integer;
public
function nextindex : integer;
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
var
resPoint : TPoint;
begin
index := 1;
resPoint := Point(nextindex, nextindex);
ShowMessage('x : ' + inttostr(resPoint.x) + ' y : ' + inttostr(resPoint.y)) ;
end;
function TForm1.nextindex: integer;
begin
index := index + 1;
result := index;
end;
end. |
Resultat : x : 3 y : 2
On pourrait s'attendre à ce que les paramètres soient résolus dans l'ordre.
C'est un bug ou c'est voulu / connu / évident ?
testé sous windows 7 et linux debian
Merci
Lazarus 1.8.4
fpc 3.0.4