Skip to content

1. Background

1. Name Type Equivalence vs. Structure Type Equivalence

  • Name Type Equivalence refers to types being considered the same if they have the same name or were declared with the same type definition.
  • Structure Type Equivalence considers types to be the same if their structure or content (such as fields and their types) is identical.

2. Easiest to Implement

  • Name type equivalence is easier to implement because it only requires checking the names or identifiers of types, rather than comparing the internal structure of types.

3. Disadvantages of Name Type Equivalence

  • A disadvantage is that two types with identical structures might not be considered equivalent if they have different names. This can lead to redundancy in code and hinder flexibility.

4. Subtype vs. Derived Type in Ada

  • A subtype in Ada refers to a constrained version of an existing type (e.g., a range restriction on an integer type), while a derived type creates a new type that is distinct from the original one.

5. Type Equivalence in C

  • C uses a combination of both name and structure type equivalence, but structure equivalence is more prominent, especially for composite types like structs.

6. Ada’s Solution to Variable Declaration Issues

  • Ada introduced the use of strong typing and explicit declarations, which help avoid ambiguity and reduce errors related to automatic type conversion or undeclared variables.

7. Exceptions in Ada

  • Ada handles exceptions using the exception block. Exceptions are raised when a specific error occurs, and the control is transferred to a handler.

8. Misuse of Exception Handling

  • Exception handling can be misused by relying on it for regular control flow, which makes the code harder to understand, less efficient, and difficult to maintain.

9. GOTO Statement in Ada

  • Ada retains the GOTO statement but restricts its use to prevent jumping into or out of subprograms, which avoids unstructured control flow and promotes better program readability.

10. Parameter Passing in Ada

  • Ada allows three modes of parameter passing: in, out, and in out. This allows for more explicit control over how arguments are passed (by value or by reference) compared to other languages of its time.

11. Is Ada’s Parameter Passing Orthogonal?

  • Yes, Ada’s parameter passing can be considered orthogonal because it consistently applies rules for how data is passed, regardless of the data type or procedure context.

12. Deadlock

  • A deadlock occurs when two or more processes are blocked because each process is waiting for a resource held by the other, leading to a situation where none of the processes can proceed.

13. Position-Independent Parameter Feature in Ada

  • It’s considered a good feature as it improves readability and maintainability by allowing parameters to be passed by name, reducing reliance on strict positional order.

14. Scoping of Exceptions in Ada

  • Ada uses lexical scoping for exceptions, meaning that the scope of an exception handler is determined by its position in the source code.

15. Why Ada Isn’t Popular Today

  • Ada is not widely popular due to its complexity, strictness, and the rise of other general-purpose languages that are easier to use and more suited to modern software development practices.

16. Problems with Global Variables (Wulf and Shaw)

  • The four problems identified are:
    • Lack of locality: Hard to track where a variable is modified.
    • Poor modularity: Functions depend on external state.
    • Difficulty in understanding and testing: Complicates the analysis of functions.
    • Lack of concurrency control: Global variables can introduce race conditions in concurrent programs.