Hi,
As it is written in Free Pascal wiki, order of parameter evaluation is not defined in FPC, but it is defined in Delphi (Delphi guarantees left-to-right evaluation order).
However, when i compile my program with FPC in Delphi-mode (-Mdeplhi), arguments in function calls are evaluated in right-to-left order). And when i compile my program in ObjectFPC-mode (-Mobjfpc), i get the same behaviour.
I tested it on the following platforms (all got the same right-to-left evaluation order):
- ArchLinux x86_64, FPC 2.6.2.
- Archlinux i686, FPC 2.6.2
- Raspbian (Debian for Raspberry Pi) armhf, FPC 2.6.2.
So, is this a compatibility bug in FPC or i just got something wrong? And is there any way to force left-to-right parameter evalution order?
P.S. Minimal working example for testing parameter evaluation is attached to this email.
program main; type TFoo = class private Next: Char; public constructor Create(initial: Char = 'a'); function Bar: String; end;
constructor TFoo.Create(initial: Char = 'a'); begin Self.Next := initial; end; function TFoo.Bar: String; begin Result := Self.Next; Self.Next := Char(Integer(Self.Next) + 1); end; procedure baz(s1: String; s2: String; s3: String); begin writeln(s1, s2, s3); end; var Foo: TFoo; begin Foo := TFoo.Create; baz(Foo.Bar, Foo.Bar, Foo.Bar); end.
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal