是否有无堆栈或无堆栈的C ++实现? [英] Are there stackless or heapless implementation of C++?

查看:127
本文介绍了是否有无堆栈或无堆栈的C ++实现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C ++标准没有提及堆栈或堆的任何内容,它们是实现特定的,这是真的。

不是C ++标准的一部分,我们最终使用它们,所以它们就像它们是语言本身的一部分,并且必须考虑内存或性能目的。

Even though they are not part of the C++ standard, we end up using them anyway, so much that it's like they are part of the language itself and have to be taken into consideration for memory or performance purpose.

因此我的问题有不使用堆栈和堆的C ++实现?

推荐答案

有些实现(例如,在IBM大型机上)不使用一个堆栈,因为大多数人会想到它,为简单的原因,硬件不支持它。相反,当你调用一个函数时,激活记录(即用于本地,参数和返回地址的空间)是从堆的(它们的版本)分配的。这些激活记录构建在链接列表中。

Some implementations (e.g., on IBM mainframes) don't use a stack as most people would think of it, for the simple reason that the hardware doesn't support it. Instead, when you call a function, an activation record (i.e., space for the locals, arguments, and return address) is allocated from (their version of) the heap. These activation records are built into a linked list.

从纯粹的抽象角度来看,这肯定是一个堆栈 - 它支持后进先出语义像任何其他堆栈。你必须看看它很抽象地称之为堆栈。如果你向人们展示了链接在一起的内存块的图,我认为大多数程序员都会将它描述为一个链表是安全的。如果你推他们,我想大多数会判断它像是的,你可以使用它以堆栈式的方式,但它仍然是一个链接列表。

From a purely abstract viewpoint, this is certainly a stack -- it supports last-in, first-out semantics, just like any other stack. You do have to look at it pretty abstractly to call it a stack though. If you showed people a diagram of the memory blocks linked together, I think it's safe to guess most programmers would describe it as a linked list. If you pushed them, I think most would judge it something like "yeah, you can use it in a stack-like manner, but it's still a linked list."

这篇关于是否有无堆栈或无堆栈的C ++实现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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