为什么c ++没有指定函数辩论的指定顺序? [英] Why doesn't c++ have a specified order for evaluating function arguements?

查看:71
本文介绍了为什么c ++没有指定函数辩论的指定顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我看来,这是任何函数式编程语言的一项非常基本且必不可少的功能,它可以知道函数调用的参数的求值顺序。我错了吗? C ++为什么不定义这个?

It seems to me that it's a very basic and necessary feature of any functional programming language to know the order in which the arguments of a function call will be evaluated. Am I wrong in this? Why doesn't C++ define this? Is it being discussed for any future version of C++?

推荐答案


为什么C ++不这样做?这样?

Why doesn't C++ do it this way?

对于初学者来说,C ++ 不是一种功能编程语言。

For starters, C++ isn't a functional programming language.

评估参数的最快方法取决于实现和体系结构,因此编译器可以选择。在C ++中,我们不支付不使用的费用,因此,如果您需要自己指定评估顺序,则可以使用命名变量显式地执行。

And the fastest way to evaluate the arguments depends on the implementation and architecture, so the compiler gets to choose. We don't pay for what we don't use, in C++, so if you need to specify an evaluation order yourself then you can do so explicitly with named variables.

尽管继续采用新标准的主题,但留下了神圣的C ++范例, C ++ 17会遗憾地添加一些评估顺序保证,从而破坏了所有这些保证。

Although, continuing the theme of newer standards leaving behind sacred C++ paradigms, C++17 will sadly add some evaluation order guarantees, ruining all of that.

这篇关于为什么c ++没有指定函数辩论的指定顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆