声明变量的兼容性
我这里有一个问题: 6. Ada 支持命名等价。给出声明:
A: array(1..10) of integer;
B: array(1..10) of integer;
A 和 B 兼容吗?如果我们将其声明为
A, B: array(1..10) of integer;
A 和 B 兼容怎么办?声明这一点的另一种方式是
Type array10 is array(1..10) of integer;
A, B: array 10;
A 和 B 兼容吗?如果 Ada 支持结构等价,那么上述三个问题的答案是什么?
I have here a question: 6. Ada supports named equivalence. Given the declaration:
A: array(1..10) of integer;
B: array(1..10) of integer;
Are A and B compatible? What if we declare this as
A, B: array(1..10) of integer;
Are A and B compatible? Yet another way of declaring this is
Type array10 is array(1..10) of integer;
A, B: array 10;
Are A and B compatible? If Ada supports structural equivalence, what will be the answer to the three questions above?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个常见问题旨在强调强类型语言(例如Ada。如需参考,请参阅 Ada 编程/类型系统 和 < a href="http://archive.adaic.com/standards/83rat/html/ratl-04-03.html" rel="nofollow noreferrer">Ada® 编程语言的设计原理。
This frequently asked question is meant to highlight the difference between name equivalence and structural equivalence in a strongly typed language such as Ada. For reference, see Ada Programming/Type System and Rationale for the Design of the Ada® Programming Language.
我们可以很好地回答 Ada 的问题。然而,这似乎是一个章节材料理解问题伪装为 Ada 问题。特别是,很大程度上取决于他们如何准确定义“兼容”、“命名等效”和“结构等效”。 (尽管后两者确实有相当明确定义的含义) 问题的一部分甚至是基于 Ada 不具备的设施的理论。如果没有这个背景,就很难回答。
答案不是在 Ada LRM 的任何地方都能找到,而是在你的书的正文中。读完这一章,你应该会有所启发。
We can answer Ada questions fairly well. However, this appears to be a chapter material comprehension question masquerading as an Ada question. In particular, a lot depends on how exactly they defined "compatible", "named equivalence", and "structural equivalence". (Although the latter two do have a fairly well-defined meaning) One part of the question is even theoretical based on a facility that Ada does not have. Without that context, it would be tough to answer.
The answer is to be found not in the Ada LRM anywhere, but in the text of your book. Read the chapter, and you should become enlightened.