Selasa, 09 April 2013

Chapter 6

Review Questions



1. What is a descriptor?Descriptor  is the collection of the attributes of at variable. In an implementation, it is an area  of memory that stores the attributes of a variable.



5.Define ordinal, enumeration, dan subrange types.
Ordinal type is one in which the range of possible values can be easily associated with the set of positive integers.
enumeration type is one in which all of the possible values, which are named constants, are provided.



12. What languages support negative subscripts?
Language that supports negative subscripts is Perl.

15. What is an aggregate constant?
Aggregate constant is the parenthesized lists of values in Fortran language.

20. What is the structure of an associative array?
 The structure of an associative array is that each element of an associative array is in fact a pair of entities, a key, and a value.

21. What is the purpose of level numbers i n COBOL records?
The purpose of level numbers in COBOL records is to indicate by their relative values the hierarchical structure of a record.

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?
The design issues for unions are:
 - Should type checking be required? Note that any such type checking must be dynamic.
- Should unions be embedded in records?


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 (or the interpreter) to a legal type.



44.Define type error
Type type is the application of an operator to an operand of an inappropriate type.


45. Define Strongly typed!
Strongly type is a name for a programming language that type errors are always detected.


50.What is name type equivalence?
Name type equivalence means that two variables have equivalent types if they are defined either in the same declaration or in declarations that use the same type name.



53. What is the primary disadvantage to structure type equivalence?
The primary disadvantage to structure type equivalence is difficult to implement.


Problem Sets

2.How are negative integers stored in memory?A negative integer could be stored in sign-magnitude notation, in which the sign bit is set to indicate negative and the remainder of the bit string represents the absolute value of the number. Sign-magnitude notation, however, does not lend itself to computer arithmetic. Most computers now use a notation called twos complement to store negative integers, which is convenient for addition and subtraction. In twos-complement notation, the representation of a negative integer is formed by taking the logical complement of the positive version of the number and adding one. Ones-complement notation is still used by some computers. In ones-complement notation, the negative of an integer is stored as the logical complement of its absolute value. Ones-complement notation has the disadvantage that it has two representations of zero.



5. What disadvantages are there in implicit deferencing of pointers, but only in certain contexts? For example , consider the implicit deference of a pointer to a record in Ada when it is used to reference a record field.When implicit dereferencing of pointers occurs only in certain contexts, it makes the language slightly less orthogonal. The context of the reference to the pointer determines its meaning. This detracts from the readability of the language and makes it slightly more difficult to learn.


9.C provides two derived data types both for name and structure type equivalence: struct and union. Make a study on when to use struct type variables and union type variables.
 With a union, we're only supposed to use one of the elements, because they're all stored at the same spot. This makes it useful when we want to store something that could be one of several types. A struct, on the other hand, has a separate memory location for each of its elements and they all can be used at once.



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.


Tidak ada komentar:

Posting Komentar