Sunday, April 7, 2013

Concepts of Programming Languages - Chapter 6


Review Questions

1. What is a descriptor?
A descriptor is the collection of the attributes of a variable.

3. What are the design issues for character sting types?
- Should strings be simply a special kind of character array or a primitive type?
- Should strings have static or dynamic length?

4. Describe the three string length options.
- Static length string, the length can be static and set when the string is created.
- Limited dynamic length strings, allow strings to have varying length up to a declared and fixed maximum set by the variable’s definition.
- Dynamic length strings, allow strings to have varying length with no maximum.

11.How does JavaScript support sparse arrays?
JavaScript sparse arrays means that the subscript values need not be contiguous.

12. What languages support negative subscripts?
Perl.

13. What languages support array slices with stepsizes?
Phyton, Perl, and Ruby.

23. What is the primary difference between a record and a tuple?
The elements of a record are named while the elements of a tuple are not named.

24. Are the tuples of Python mutable?
No.

27. What is the action of the Scheme function CAR?
The function CAR returns the first element of its list parameter.

28. What is the action of the F# function tl?
The function tl returns all elements of its list parameter except the first one.

32. What are the design issues for unions?
- Should type checking be required? Note that any such type checking must be dynamic.
- Should unions be embedded in records?

33. Are the unions of Ada always type checked?
Yes.

34. Are the unions of F# discriminated?
Yes.

43. What is a compatible type?
A compatible type is one that either is legal for the operator or is allowed under language rules to be implicitly converted by compiler-generated code to a legal type.


Problem Set

7. Compare the pointer and reference type variable in C++.
A C++ reference type variable is a constant pointer that’s always implicitly dereferenced.

9. C provides two derived data types both for name and structure type equivalence: struct and union. Makes a study on when to use struct type variables and union type variables.
If all data members of the variables are to be used at once then struct type variables are required, otherwise union type variables should be used.

21. In what way is dynamic type checking better than static type checking?
Dynamic type checking detects error at compile time and it is better than detecting error at run time.

No comments:

Post a Comment