Wednesday 5 November 2014

Assignment #6 (Concepts of Programming Languages Chapter 6 Problem Set)


Problem Set:

15.What are the arguments for and against Java’s implicit heap storage recovery, when compared with the explicit heap storage recovery required in C++? Consider real-time systems. 
Answer:
Implicit eliminates the creation of dangling pointers. Disadv: cpu-time to do recovery, sometimes when there’s plenty of heap storage so recovery isn’t necessary.

16.What are the arguments for the inclusion of strong type checking in Java, although they were not included in C or C++?
Answer:
Java are strongly typed in the same sense as Ada. Types can be explicitly cast, which could result in a type error. However, there are rules of a language have an important effect on the value of an arithmetic operator with one floating-point operand and one integer operand is legal. The value of the integer operand is coerced to floating-point, and a floating point operation takes place. This is what is usually intended by the programmer.

17.  What kind of conversion is called a nonconverting cast? Explain with example in Ada language
Answer:

Ada is nearly strongly typed. It is only nearly strongly typed because it allows programmers to breach the type-checking rules by specifically requesting that type checking be suspended for a particular type conversion. This temporary suspension of type checking can be done only when an instantiation of the generic function Unchecked_Conversion is called. Such functions can be instantiated for any pair of subtypes. One takes a value of its parameter type and returns the bit string that is the parameter’s current value. No actual conversion takes place; it is merely a means of extracting the value of a variable of one type and using it as if it were of a different type. This kind of conversion is sometimes called a nonconverting cast.

Assignment #6 (Concepts of Programming Languages Chapter 6 Review Questions)

Review Questions :

16.What array operations are provided specifically for single-dimensioned arrays in Ada?   
Answer:
Catenation specified by the ampersand (&)

17. Define row major order and column major order.
Answer:
Row major order: the elements of the array that have as their first subscript the lower bound value of that subscript are stored first, followed by the elements of the second value of the first subscript, and so forth. If the array is a matrix, it is stored  by rows.
Column major order: the elements of an array that have as their last subscript the lower bound value of that subscript are stored first, followed by the elements of the second value of the last subscript, and so forth. If the array is a matrix, it is stored by columns.

18. What is an access function for an array? 
Answer:
Access function maps subscript expressions to an address in the array

20. What is the structure of an associative array? 
Answer:
Unordered collection of elements indexed by an equal number of KEYS.

21.  What is the purpose of level numbers in COBOL records?
Answer:
The level numbers in COBOL records are used to establish a hierarchical structure of related records.

22. Define fully qualified and elliptical references to fields in records.
Answer:
Fully qualified reference to fields in records is one in which all intermediate record names, from the larges enclosing record to  the specific field, are named in the reference.
Elliptical references to fields in records is when the field is named, but any or all of the enclosing record names can be omitted, as long as the resulting reference is unambiguous in the referencing environment.

23. What is the primary difference between a record and a tuple?
Answer:
A tuple is similar to a record, but do not have names for their constituent parts.            

24. Are the tuples of Python mutable?
Answer:

No, they aren’t.