声明变量的兼容性

发布于 2024-09-11 17:41:09 字数 368 浏览 2 评论 0原文

我这里有一个问题: 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 技术交流群。

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

发布评论

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

评论(2

睫毛上残留的泪 2024-09-18 17:41:09

这个常见问题旨在强调强类型语言(例如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.

醉殇 2024-09-18 17:41:09

我们可以很好地回答 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.

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