Name: William Gunawan
NIM: 1601211306
Instructor: Tri Djoko Wahjono
REVIEW QUESTIONS
1. What is a descriptor?
A descriptor is the collection of the attributes of a variable. In
an implementation, a descriptor is an area of memory that stores the attributes
of a variable.
3. What are the design issues for character string types?
The two most important design issues that are specific to character string types are the following:
– 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: to allow strings to have varying length up to a
declared and fixed maximum set by the variable’s definition.
-dynamic length strings: to allow strings to have varying length with no maximum,
as in JavaScript, Perl, and the standard C++ library.
5. Define ordinal, enumeration, and subrange types.
-An ordinal type is one in which the range of possible values can be easily
associated with the set of positive integers.
-An enumeration type is one in which all of the possible values, which are
named constants, are provided, or enumerated, in the definition.
-A subrange type is a contiguous subsequence of an ordinal type.
8. What are the desgin issues for arrays?
The primary design issues specific to arrays are the following:
• What types are legal for subscripts?
• Are subscripting expressions in element references range checked?
• When are subscript ranges bound?
• When does array allocation take place?
• Are ragged or rectangular multidimensioned arrays allowed, or both?
• Can arrays be initialized when they have their storage allocated?
• What kinds of slices are allowed, if any?
17. Define row major order and column major order.
-In 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.
-In 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.
18. What is an access function for an array?
The access function for a multidimensional array is the mapping of its
base address and a set of index values to the address in memory of the element
specified by the index values.
20. What is the structure of an associative array?
In an
associative array, however, the user-defined keys must be stored in the structure.
So each element of an associative array is in fact a pair of entities, a key and a
value.
31. Define union, free union, and discriminated union.
-A union is a type whose variables may store different type values at different
times during program execution.
-free unions, because programmers
are allowed complete freedom from type checking in their use.
-discriminated union: Type checking of unions requires that each union construct include a type
indicator.
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 (or the interpreter) to a legal type.
44. Define type error.
A type error is the application of an operator to an operand of an inappropriate
type.
47. What is a nonconverting cast?
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.
48. What languages have no type coercions?
ML and F#.
Continue reading →