Question

Question 2 Whether two types are structurally equivalent is ultimately a matter of inter- pretation: the...

Question 2 Whether two types are structurally equivalent is ultimately a matter of inter- pretation: the language designer decides which differences between two types are significant andwhich ones are not. On page 304 of the textbook, the following algorithm for determining structuralequivalence of two types A and B is given:1 Every type T can be represented as a string sT definedinductively:

If T is a built-in type, sT is its name.

If T is a composite of a sequence of subtypes T1, ..., Tk, then sT consists of the type constructor

used to construct T followed by the strings sT1 , . . . , sTk .
For example, the string sT for the following type T is “struct char pointer int”:

struct T {
    char x;
    int *y;

};

Two types A and B are structurally equivalent if and only if sA = sB.

(a) Argue why you cannot use this definition of type equivalence to decide whether the following

two types A and B are equivalent:

struct A {
    char x;
    struct B *y;
};
struct B {
    char x;
    struct A *y;
};

Homework Answers

Answer #2

answered by: anonymous
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
In the following C code, Which variable if NOT of primitive data type? A. a B....
In the following C code, Which variable if NOT of primitive data type? A. a B. b C. c D. d int a = 10; double b = 20.0; float c = false; char d[5] = "Hello"; // here we define a string In programming language C, the implementation of a string data type is limited dynamic length, which means the length of a string variable is fixed once it has been defined. A. True B. False In C# programming...
Question 1 Which statement is false about what Data Types defines Question 1 options: What values...
Question 1 Which statement is false about what Data Types defines Question 1 options: What values a variable cannot hold? How much memory will be reserved for the variable? What value a variable will hold? How the program will use the data type? Question 2 Using the structure below, which of the following statements about creating an array (size 20) of structures are not true? struct Employee{     string emp_id;     string emp_name;     string emp_sex; }; Question 2 options:...
Miscellaneous C knowledge. (Put all answers in the same q5.txt file, they’re all short.) (a) [2...
Miscellaneous C knowledge. (Put all answers in the same q5.txt file, they’re all short.) (a) [2 marks] On an old 16-bit computer system and its C compiler,sizeof(double)=8andsizeof(int)=2. Given the two type definitions below, what weresizeof(s)andsizeof(lingling)on that system? Assume that ins, there is no gap between the twofields. typedef struct s { double r[5];int a[5]; } s; typedef union lingling { double r[5];int a[5]; } lingling; (b) [2 marks] Given the following declarations, two questions: What is the type ofq? Whatis...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as possible: What is a checked exception, and what is an unchecked exception? What is NullPointerException? Which of the following statements (if any) will throw an exception? If no exception is thrown, what is the output? 1: System.out.println( 1 / 0 ); 2: System.out.println( 1.0 / 0 ); Point out the problem in the following code. Does the code throw any exceptions? 1: long value...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT