home *** CD-ROM | disk | FTP | other *** search
/ Shareware Supreme Volume 6 #1 / swsii.zip / swsii / 098 / ARMFIX.ZIP / ARMFIX.TXT next >
Text File  |  1993-07-23  |  13KB  |  421 lines

  1. ==========
  2. c.plus.plus/main #2241, from bstroustrup, 8558 chars, Sun Dec  2 21:40:21 1990
  3. ----------
  4. TITLE: errata for ARM
  5. Here are some errata to
  6.  
  7.         Ellis&Stroustrup: The Annotated C++ Reference Manual
  8.         Addison Wesley, 1990. ISBN 0-201-51459-1
  9.  
  10. I am not including simple spelling errors in this list only things
  11. that might affect the understanding of C++. Except for moving
  12. of templates and exception handling from the commentary to the
  13. manual proper these changes do not represent changes to C++;
  14. they are  simply clarifications and corrections to the book text.
  15.  
  16. The old ed notation for replacement s/old/new/ is used. Quotes `'
  17. are use to indicate constant width font.
  18.  
  19. This errata reflects changes done for the third printing of the ARM.
  20.  
  21. Thanks to all who sent comments.
  22.  
  23. Preface:
  24.  
  25.         cut the paragraph
  26.  
  27.         ``The commentary contains descriptions of templates and
  28.         exception handling that are still only experimental
  29.         features in C++.''
  30.  
  31. Chapter 1:
  32.  
  33. pg3: cut the sentense
  34.  
  35.         ``In addition, commentary sections present two proposed
  36.         extensions of C++: templates (Chapter 14) and exception
  37.         handling (Chapter 15).
  38.  
  39. Chapter 3:
  40.  
  41. pg15: first line: s/statement/global declaration/
  42.  
  43. pg16: at the end of thesecond non-commentary paragraph add
  44.  
  45.         Similarly, a hidden enumeration name can be used when
  46.         appropriately (sc7.1.6) prefixed with `enum.'
  47.  
  48. pg17: cut
  49.         int x = 12;
  50.  
  51. pg22: comment near bottom of page s/sc3.2/sc3.2c/
  52.  
  53. pg24: comment near top of page s/sc3.2.2/sc3.2.2c/
  54.  
  55. pg28: for both `Integral Limits' and `Floating Limits' replace the
  56.         statement about magnitudes' by
  57.  
  58.         Where a maximum value is given below,
  59.         it is the minimum value that will satisfy ANSI;
  60.         an implementation may provide larger values.
  61.         Where a minimum value is given below,
  62.         it is the maximum value that will satisfy ANSI;
  63.         an implementation may provide smaller values.
  64.  
  65. Chapter 4:
  66.  
  67. pg32: swap the comments on the example near the bottom of the page.
  68.  
  69. pg40: replace the last paragraph by
  70.  
  71.         Conversions for the types `char' and `w_char' are not shown
  72.         because `w_char' is a synonym for some integer type, usually
  73.         `short' or `unsigned short,' and it is also implementation
  74.         dependent whether `char' is signed or unsigned.
  75.  
  76. Chapter 5:
  77.  
  78. pg51:   s/g[1]/p[1]/ twice
  79.         s/g[2]/p[2]/
  80.  
  81. pg59:   s/sc10/sc8.2.4/
  82.         s/new char/new char[0]/ twice
  83.  
  84. pg64:    s/*q++/(*q)++/
  85.  
  86. pg78:   replace the first sentence in the second paragraph by:
  87.  
  88.         If both the second and the third expressions are of
  89.         arithmetic type, then if they are of the same type
  90.         the result is of that type; otherwise the usual arithmetic
  91.         conversions are performed to bring them to a common type.
  92.  
  93. Chapter 6:
  94.  
  95.         change   T(*d)(double(3)); // expression-statement
  96.         to       T(*d)(double(3)); // declaration
  97.  
  98. Chapter 7:
  99.  
  100. pg98: 3rd non-commentary paragraph:
  101.  
  102.         add that `static' can be applied to anonymous unions.
  103.  
  104. pg108: s/_dcl.fct.dcl_/sc8.2.5/
  105.  
  106. pg109: Replace
  107.  
  108.         ``The effect of any write operation on any part of such an
  109.         object is undefined.''
  110.  
  111.         by
  112.  
  113.         ``The effect of a write operation on any part of such an
  114.         object is either an addressing exception or the same as if
  115.         the object had been non-const.''
  116.  
  117. pg110: replace
  118.         
  119.         const pi = 22/7;
  120.  
  121.        by
  122.  
  123.         const pi = 3;     // :-)
  124.  
  125. pg111: s/qualified-typedef-name/qualified-type-name/
  126.  
  127. Chapter 8:
  128.  
  129. pg139: s/except in default arguments(sc8.2.6//
  130.  
  131. pg145: middle of page
  132.  
  133.         s/member function definition/nonstatic member function definition/
  134.  
  135. pg147:
  136.  
  137.         replace  void another handler(const char*);
  138.         by       void another handler(const char* ...);
  139.  
  140. p150: add to 4th noncommentary paragraph:
  141.  
  142.         So are members of static class objects.
  143.  
  144. pg154: first example s/a, b/{ a, b }/
  145.  
  146. pg157: s/funct1/f1/
  147.  
  148. pg158: all cross references in sc8.1.2 should be to commentary sections:
  149.         s/sc*/sc*c/
  150.  
  151. Chapter 9: last example
  152.  
  153.         initialize `p' by `new s;'
  154.  
  155. pg174: last non-commentary paragraph, s/and 9.3//
  156.  
  157. pg184: add to second paragraph
  158.  
  159.         An unnamed field is not a member and cannot be initialized.
  160.  
  161. pg188: last paragraph
  162.  
  163.         s/enclosing function/enclosing scope/ twice
  164.  
  165. pg189: second to last paragraph
  166.  
  167.         Type names obey exactly the same scope rules as other names.
  168.         In particular, type names defined within a class declaration
  169.         cannot be used outside their class without qualification.
  170.  
  171.         class X {
  172.         public:
  173.                  typedef int I;
  174.                  class Y { /* ... */ };
  175.                  I a;
  176.         };
  177.  
  178.         I b;     // error
  179.         Y c;     // error
  180.         X::Y d;  // ok
  181.  
  182. Chapter 10:
  183.  
  184. pg196:  s/sc4.6/sc4.7/
  185.  
  186. pg198:  s/sc10.1/sc10.1c/
  187.         s/sc10.10/sc10.10c/
  188.  
  189. pg206:  s/sc10.8/sc10.8c/
  190.  
  191. pg208:  s/sc7.1.1/sc7.1.2/
  192.  
  193. pg209:  s/sc7.1.1/sc7.1.2/
  194.  
  195. pg222:  s/sc10.4/sc10.4c/
  196.  
  197. pg225:  first paragraph s/`pa' and `pc'/`pb' and `pc'/
  198.  
  199. pg228:  s/sc10.8/sc10.8c/
  200.  
  201. pg229:  s/sc10.2/sc10.2c/
  202.         s/sc8.1.2/sc8.1.2c/
  203.         s/sc10.10/sc10.10c/
  204.  
  205. pg231:  s/call-by-value/call-by-name/
  206.  
  207. pg232: 3rd paragraph s/nonvirtual member/non-inline virtual member/
  208.  
  209. pg235: The picture should look something like this:
  210.  
  211.         BW & BMW's vtbl:
  212.         vptr ---------> &BW::f     0
  213.         BW part  &MW::g   delta(BW)
  214.         &BMW::h  0
  215.         &W::k    delta(W)
  216.  
  217.         MW's vtbl:
  218.         vptr --------->   &BW::f   -delta(MW)
  219.         MW part  &MW::g   0
  220.         &BMW::h  -delta(MW)
  221.         &W::K    delta(W)-delta(MW)
  222.  
  223.         BMW part
  224.  
  225.         vptr --------->   W's vtbl:
  226.         W part   &BW::f   -delta(W)
  227.         &MW::g   delta(MW)-delta(W)
  228.         &BMW::H  -delta(W)
  229.         &W::k    0
  230.  
  231. pg237: Replace the page by:
  232.  
  233.         class LotterySimulation
  234.             : public Lottery ,
  235.             public GraphicalObject {
  236.             // ...
  237.             virtual int l_draw() = Lottery::draw;
  238.             virtual void go_draw() = GraphicalObject::draw;
  239.         };
  240.  
  241.         This would extend the pure virtual syntax in a natural manner.
  242.  
  243.         However, it was noted by Doug McIlroy that this problem does
  244.         have a solution within \*C. Renaming can be achieved through
  245.         the introduction of an extra class for each class with a
  246.         virtual function that needs to be overridden by a function with
  247.         a different name plus a forwarding function for each such function.
  248.         For example:
  249.  
  250.         class LLottery : public Lottery {
  251.             virtual int l_draw() = 0;
  252.             int draw() // overrides Lottery::draw
  253.                 { return l_draw(); }
  254.         };
  255.  
  256.         class GGraphicalObject : public GraphicalObject {
  257.             virtual int go_draw() = 0;
  258.             void draw() // overrides GraphicalObject::draw
  259.                 { go_draw(); }
  260.         };
  261.  
  262.         class LotterySimulation
  263.             : public LLottery ,
  264.             public GGraphicalObject {
  265.             // ...
  266.             int l_draw();
  267.             void go_draw();
  268.         };
  269.  
  270.         Consequently, a language extension to express renaming is not
  271.         necessary and is only worthwhile if the need to resolve such
  272.         name clashes proves common.
  273.  
  274. Chapter 12:
  275.  
  276. pg270:  s/sc12.1/sc12.1c/
  277.         s/sc12.2/sc12.2c/
  278.  
  279. Chapter 13:
  280.  
  281. pg328: 2nd paragraph of commentary section: s/f()/g()/
  282.  
  283. Chapter 14:
  284.  
  285. pg341: remove `Experimental' and the `Commentary' heading.
  286.  
  287.         (templates were voted into C++ by X3J11 in July 1990).
  288.  
  289. pg343: last non-commentary paragraph /class members/static class members/
  290.  
  291. pg346 near bottom of page
  292.  
  293.         s/template-arg/template-argument/
  294.         s/template-arg-list/template-argument-list/
  295.  
  296. pg347 near top of page
  297.  
  298.         s/template-arg/template-argument/
  299.  
  300. pg351: last paragraph s/char*/char**/ twice
  301.  
  302. Chapter 15:
  303.  
  304. pg353: remove `Experimental' and the `Commentary' heading.
  305.  
  306.         (exceptions were voted into C++ by X3J11 in November 1990).
  307.  
  308. pg357: first paragraph s/expression/object/
  309.  
  310. pg 359: first paragraph of 15.4:
  311.  
  312.         A handler with type `T' , `const T' , `T&' , or `const T&'
  313.         is a match for a throw-expression with an object of type
  314.         `E' if
  315.  
  316.         [1] `T' and `E' are the same type, or
  317.  
  318.         [2] `T' is an accessible (sc4.6) base class of `E'
  319.         at the throw point, or
  320.  
  321.         [3] `T' is a pointer type and `E' is a pointer type
  322.         that can be converted to `T' by a standard pointer
  323.         conversion (sc4.6) at the throw point.
  324.  
  325. pg 367: add
  326.  
  327.         15.7 Exceptions and Access
  328.  
  329.         The formal argument of a catch clause obeys the same access rules
  330.         as an argument of the function in which the catch clause occurs. 
  331.  
  332.         An object may be thrown if it can be copied and destroyed in the
  333.         context of the function in which the throw occurs.
  334.  
  335.         Commentary:
  336.  
  337.         Note that since a base class of a thrown object must
  338.         be accessible, an object with two uses of a class as
  339.         a base cannot be thrown unless both are virtual bases;
  340.         otherwise the throw would be ambiguous.
  341.  
  342.         Note also that an object cannot be caught by a handler
  343.         for a class that is a private base class of the object's
  344.         class; a private class is considered an implementation detail.
  345.  
  346.         End commentary
  347.  
  348. Chapter 16:
  349.  
  350. pg380: s/(((/((/
  351.  
  352. Chapter 18:
  353.  
  354. pg402:  s/sc7.1.1/sc7.1.2/
  355.  
  356.         Replace the line about void* by
  357.  
  358.         A pointer to any non-const and non-volatile object type
  359.         can be assigned to a `void*'; sc4.6. This is also in ANSI C.
  360.  
  361.         A pointer to function can be assigned to a `void*'; sc4.6.
  362.  
  363. pg404: s/enclosing the scope/enclosing the `struct'/.
  364. ==========
  365. c.plus.plus/main #2046, from wcowley, 2494 chars, Sat Oct 20 13:41:32 1990
  366. Comment(s). 
  367. ----------
  368. TITLE: Question on vtbls
  369. Page 235 in section 10.10c of the ARM contains the following chart:
  370.  
  371.         +----------+     +->+---------+----------------------+
  372.         |          |     |  | &BW::f  |               0      |
  373.         |  vptr----|-----+  | &MW::g  |   0      - delta(BW) |
  374.         | MW part  |        | &BMW::h |               0      |
  375.         |          |        | &W::k   |   0      - delta(W)  |
  376.         +----------+        +---------+----------------------+
  377.         |          |       
  378.         |  vptr----|------->+---------+----------------------+      
  379.         | BW part  |        | &BW::f  |               0      |
  380.         |          |        | &MW::g  |   0      - delta(BW) |
  381.         +----------+        | &BMW::h |   0      - delta(BW) |
  382.         |          |        | &W::k   | delta(W) - delta(BW) |
  383.         |          |        +---------+----------------------+
  384.         | BMW part |       
  385.         |          |       
  386.         +----------+     +->+---------+----------------------+
  387.         |          |     |  | &BW::f  | delta(BW)- delta(W)  |
  388.         |  vptr----|-----+  | &MW::g  |   0      - delta(W)  |
  389.         | W part   |        | &BMW::h |   0      - delta(W)  |
  390.         |          |        | &W::k   |               0      |
  391.         +----------+        +---------+----------------------+
  392.                            
  393.  
  394. This is in reference to this inheritance DAG:
  395.  
  396.                         W { f, g, h, k }
  397.                          /      |     \ 
  398.                         /       |      \
  399.                        /        |       \
  400.                       /         |        \
  401.               BW { g }\         |        /MW { g }
  402.                        \        |       /
  403.                         \       |      /
  404.                          \      |     /
  405.                           \     |    /
  406.                            BMW { h }
  407.  
  408. f, g, h, k are virtual functions, W is a public virtual base class of
  409. BW, MW, and BMW; BW and MW are public base classes of BMW.
  410.  
  411. It seems to me that the vtbl for MW and BMW should actually be:
  412.  
  413.                             +---------+----------------------+
  414.                             | &BW::f  |            delta(BW) |
  415.                             | &MW::g  |               0      |
  416.                             | &BMW::h |               0      |
  417.                             | &W::k   |            delta(W)  |
  418.                             +---------+----------------------+
  419.  
  420. Is this right, or am I quite confused as to what's going on? :)
  421.