Delphi XE register 调用约定的参数执行顺序

s11ss 2017-10-31 02:20:42
XE下:
procedure TForm1.FormCreate(Sender: TObject);
function f(s: string): byte;
begin
result := 1;
showmessage(s)
end;
procedure p(s1,s2: byte);
begin
end;
begin
p(f('1'),f('2'))
end;

执行结果先弹2,再弹1。
但是帮助文档 ms-help://embarcadero.rs_xe/rad/Procedures_and_Functions.html#Calling_Conventions 中写的:
引用
The register and pascal conventions pass parameters from left to right; that is, the left most parameter is evaluated and passed first and the rightmost parameter is evaluated and passed last.

根据帮助文档,应该是先弹1,再弹2。
求解!
...全文
292 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
s11ss 2017-10-31
  • 打赏
  • 举报
回复
引用 2 楼 DelphiGuy 的回复:
就你的例子,32位代码输出2 1,64位代码输出1 2,可见求值顺序是编译器相关的。
应该是编译器相关!还仔细看了帮助,想不到连帮助都是错的,更不用说网上那些文章了。。。
  • 打赏
  • 举报
回复
就你的例子,32位代码输出2 1,64位代码输出1 2,可见求值顺序是编译器相关的。
  • 打赏
  • 举报
回复
那个说法有误,参见:http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Procedures_and_Functions_(Delphi) For the register and pascal conventions, the evaluation order is not defined.

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧