[fpc-pascal] Is this behavior related to calling convention?
I have this function: function Compare(v1, v2: Integer): Integer; And called like this: Result := Compare(stack.Pop, stack.Pop); The behavior is that the second Pop is evaluated first, thus reversed the meaning of the function. Is it true that all parameter evaluation goes from right to left? Thanks! Xiangrong ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Is this behavior related to calling convention?
On 07 Dec 2013, at 09:40, Xiangrong Fang wrote: > Is it true that all parameter evaluation goes from right to left? The order in which parameters are evaluated is unrelated to the calling convention. This order has always been undefined in FPC, and it is also undefined in recent versions of Delphi. Jonas___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Re: Is this behavior related to calling convention?
Nope, calling convention only specifies parameter passing order, not parameter evaluation order. If you want to specify exactly how the parameters are evaluated, put each in a local variable first, according to your order needs. -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Is-this-behavior-related-to-calling-convention-tp5717622p5717624.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Is this behavior related to calling convention?
Am 2013-12-07 10:15, schrieb Jonas Maebe: > The order in which parameters are evaluated is unrelated to the calling convention. > This order has always been undefined in FPC, and it is also undefined in recent versions of Delphi. I am wondering what the advantage is to *not* garantee a left to right order. I can't think of a situation where changing this order makes any sense. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Is this behavior related to calling convention?
In our previous episode, J?rgen Hestermann said: > I am wondering what the advantage is to *not* garantee a left to right order. Undefined order allows to do the evaluation that needs the most temps first I guess, which reduces spilling. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Is this behavior related to calling convention?
On 07 Dec 2013, at 18:50, Jürgen Hestermann wrote: > I am wondering what the advantage is to *not* garantee a left to right order. http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/compiler/ncal.pas?view=markup#l3268 Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal