it is the way pointer being allowed to be used that makes the difference


所有跟贴·加跟贴·新语丝读书论坛

送交者: meiyou 于 2009-10-27, 12:50:03:

回答: fortran actually has pointers since fortran 90. 由 steven 于 2009-10-27, 12:40:42:

See this from the internet:

=========================================
Of course not. The performance differences arise from differences in the
semantics of C and Fortran, primarily in the semantics of pointers and
the need for their ubiquitous use in C. Fortran doesn't allow arithmetic
on pointers, and requires that an object have the "target" attribute in
order for it to be a pointer's target. Fortran doesn't require one to
use pointers for "output" procedure arguments. Fortran doesn't consider
arrays and pointers to be the same thing "under the covers." Fortran
functions can return composite objects instead of pointers to them.

Fortran pointer semantics allow optimizers to do a better job of alias
analysis, and therefore a better job of register optimization. Fortran
also provides "allocatable" and "automatic" objects, which carry much of
the burden carried by pointers in C and C++, but have semantics that are
very restricted compared to pointer semantics, which in turn give more
aid to optimization.

Pointer optimization in C has been shown to be NP hard, so it's
unfortunate (for optimizers) that other features of the design of C
require the use of pointers so ubiquitously. The amazing thing is that
the optimization heuristics that some very clever people have invented to
attack this hopeless problem in C and C++ optimizers work as well as they
do. I've lost the report "Pointer optimization in C is NP hard," which
(if I remember correctly) was a Bell System Technical Report. I thought
Barbara Ryder wrote it, but she denied it. There is active work in this
area. See http://www.cs.wisc.edu/wpis/papers/toplas97a.ps and the
references therein.




所有跟贴:


加跟贴

笔名: 密码: 注册笔名请按这里

标题:

内容: (BBCode使用说明