在指针/引用之前

发布于 2024-09-16 09:20:22 字数 165 浏览 3 评论 0原文

因此,像 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

贪恋 2024-09-23 09:20:22

取决于实现,但在一个 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.

二手情话 2024-09-23 09:20:22

FORTRAN 似乎假设参数“好像”通过引用传递。

FORTRAN seemed to assume arguments were passed "as if" by reference.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文