在指针/引用之前
因此,像 perl、java 和 C 这样的现代语言通过指针(如果编写正确的话)传递数据(例如函数参数),因此当您传入变量时,会在堆栈上写入该变量的地址。我正在研究指针之前的旧版本的 Fortran,并且想知道:数据在指针之前是如何传递的?如果我将一个大数组传递给子例程,该数组是否会被写入堆栈而不是指向数组的指针?
So modern languages like perl, java, and C pass data around (function parameter for example) via pointers (if written correctly that is), so on the stack when you pass a variable in, the address of that variable is written. I was looking into old versions of fortran, before pointers, and was wondering: How was data passed around before pointers? If I passed in a large array to a subroutine, would that array get written to the stack as opposed to a pointer to the array?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
取决于实现,但在一个 Fortran IV 编译器中,函数(在后台)通过指向数组所在的 BSS 的指针进行调用。该(依赖于实现的)细节不是语言语法的一部分,因此 F4 文档中缺少该细节。
Depends on the implementation, but in one Fortran IV compiler the function is (under the hood) called with a pointer into BSS, where the array lives. That (implementation-dependent) detail is not part of the language syntax and so is missing from the F4 docs.
FORTRAN 似乎假设参数“好像”通过引用传递。
FORTRAN seemed to assume arguments were passed "as if" by reference.