您是否遇到过三级间接的任何原因?
翻阅我最喜欢的一本书(Ellen Ullman 的《The Bug》),有一小段内容,一个程序员在三个间接级别上与另一个程序员对峙:
***object_array = ***winarray;
我得到了双重间接的想法 - 一种将指针传递到函数的方法,并且允许它指向函数内创建的对象。
但是您是否遇到过使用三层(或更多)间接层的任何理由?
Just flicking through one of my favourite books (Ellen Ullman's The Bug) and there is a small bit where one programmer confronts another over three levels of indirection:
***object_array = ***winarray;
I get the idea of double indirection - a way of passing a pointer into a function, and allowing it to point to an object created within the function.
But have you come across any reason to use three (or more) levels of indirection?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
当然
4 维数组。
对于这样的数组的应用程序来说也不需要太多。 说某种查找表。 我有 8 个或更多维度的查找表。
Sure
4 dimensional arrays.
It doesn't take too much for an application for such an array either. Say some sort of lookup table. I've had lookup tables of 8 and more dimensions.
正如 David Wheele 所说:“计算机科学中的任何问题都可以通过另一层间接解决。” 几乎可以肯定,您已经使用了这样的一行的三层间接:
毕竟,芯片是通过两层 L1 和 L2 缓存来间接访问内存的。 操作系统通过虚拟内存页间接访问内存。 您的 C# 编译器通过虚拟机中的对象间接访问内存。 当然,它没有一长串星号,但那是因为所有这些间接都是用机器、操作系统或编译器等事物抽象出来的。
As David Wheele said: "Any problem in computer science can be solved with another layer of indirection." You have almost certainly used three layers of indirection with a line like this:
After all, the chip is indirecting memory access through two layers of L1 and L2 cache. And the OS is indirecting the memory access via virtual memory pages. And your C# compiler is indirecting the memory access via objects in a virtual machine. Sure, it doesn't come with a long line of asterixes, but that's because all of these indirections are abstracted with things liks a machine, an OS or a compiler.
您现在可能正在运行 3 个或更多级别。 可能是在 Mac(或 VM)上的 Windows 中运行的浏览器中的 javascript 上的 jQuery,通过在...中运行的远程访问。
或者,从更接近您的问题上下文的另一个角度来看,3 个级别是我们最常见的工件。
什么是指向窗口容器中控件的指针?
You're possibly running at 3 or more levels right now. Could be jQuery on javascript in a browser running in Windows on a Mac (or in a VM) via Remote Access running in ....
Or, from another perspective closer to your question's context, 3 levels is the most common artifact we have.
What's a pointer to a control in a container in a Window?
不,我从未真正见过或使用过它(据我所知,至少在没有合理的 typedef 来使其不那么令人困惑的情况下),但我可以设计一个可能是[可疑]有效使用的示例:
我实际上不会做我在这里所做的事情。 这只是一个如何最终获得三个指针级别的示例。 不过,我无法想象您经常遇到这种情况。
No, I've never actually seen or used it (as far as I can recall, and at least not without sensible typedefs to make it less fubar), but I can contrive an example of what might be a [questionably] valid use:
I wouldn't actually do what I've done here. It's just an example of how you could end up with three pointer levels. I can't imagine you running into this kind of scenario very often, though.