Monday, April 8, 2013

Answers of Concepts of Programming Languages Chapter 6


1. A descriptor is the collection of the attribute of a variable
2.
3. the design issues are : whether strings should be simply a special kind of character array or a primitive type and whether string should have static or dynamic length
4. The three string length options are : static length string, dynamic length string, and limited dynamic length string
5.
6.
7.
8. design issues for arrays are :
   - 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 array allowed, or both?
   - can arrays be initialized when they have their storage allocated?
   - what kinds of slices are allowed, if any?
9.
10. a reference to a nonexistent element yields undef, but no error will be reported
11. when we assign an index which is more than the initialized one, it will automatically add the gap with undefined datas and the statement will run
12. Perl, Ruby, Lua
13
14. Ada provides the => operator that makes users available to initialize specified value to specifid index.
15. Parenthized lists of constants
16. Ada provides catenation for the single dimensioned array
17. row major order : the elements of the array that have as their first subscirpt the lower bound value of that subscript are stored first
    column major order : the elements of the array that have as their last subscirpt the lower bound value of that subscript are stored first
18.
19
20
21. level numbers are used to indicate by their relative values the hierarchical structure of the record
22.
23. tuple is similar to record, but in tuple, the elements are not named
24. no

Problem set
1.
2. negative integer is stored in sign-magnitude notation
3. precision is the accuracy of the fractional part of a value
   range is a combination of the range of fractions and range of exponents
4.
5
6. in Java, boolean type can't be represented by any integer, while in C, it can.
7. reference type variable in C++ is a constant pointer that is always implicitly dereferenced, while pointer requires explicit dereference
8. Java reference type variable is not a constant, thus it is safer.
9. struct is used to store more than one data types into a group, while union is used to group multiple variables to share the memory
10.
11
12
13. reference type is used when we want to pass it to another function, while value is used when it is required by the function itself.
    Example : void print(int *jumlah) {}
              void main() {int value=0; }

No comments:

Post a Comment