schweitz@lexvmc.vnet.ibm.com ("Eric Schweitz") (03/25/91)
In case some other folks are interested: Eric ********************************************************************** ------------------------------------------------------ >From bs@alice.att.com Fri Nov 30 20:41:55 1990 Path: ulysses!andante!alice!bs From: bs@alice.att.com (Bjarne Stroustrup) Newsgroups: comp.lang.c++ Subject: errata for the ARM Message-ID: <11694@alice.att.com> Date: 1 Dec 90 01:41:55 GMT Organization: AT&T Bell Laboratories, Murray Hill NJ Lines: 360 Status: R Here are some errata to Ellis&Stroustrup: The Annotated C++ Reference Manual Addison Wesley, 1990. ISBN 0-201-51459-1 I am not including simple spelling errors in this list only things that might affect the understanding of C++. Except for moving of templates and exception handling from the commentary to the manual proper these changes do not represent changes to C++; they are simply clarifications and corrections to the book text. The old ed notation for replacement s/old/new/ is used. Quotes `' are use to indicate constant width font. This errata reflects changes done for the third printing of the ARM. Thanks to all who sent comments. Preface: cut the paragraph ``The commentary contains descriptions of templates and exception handling that are still only experimental features in C++.'' Chapter 1: pg3: cut the sentense ``In addition, commentary sections present two proposed extensions of C++: templates (Chapter 14) and exception handling (Chapter 15). Chapter 3: pg15: first line: s/statement/global declaration/ pg16: at the end of thesecond non-commentary paragraph add Similarly, a hidden enumeration name can be used when appropriately (sc7.1.6) prefixed with `enum.' pg17: cut int x = 12; pg22: comment near bottom of page s/sc3.2/sc3.2c/ pg24: comment near top of page s/sc3.2.2/sc3.2.2c/ pg28: for both `Integral Limits' and `Floating Limits' replace the statement about magnitudes' by Where a maximum value is given below, it is the minimum value that will satisfy ANSI; an implementation may provide larger values. Where a minimum value is given below, it is the maximum value that will satisfy ANSI; an implementation may provide smaller values. Chapter 4: pg32: swap the comments on the example near the bottom of the page. pg40: replace the last paragraph by Conversions for the types `char' and `w_char' are not shown because `w_char' is a synonym for some integer type, usually `short' or `unsigned short,' and it is also implementation dependent whether `char' is signed or unsigned. Chapter 5: pg51: s/g[1]/p[1]/ twice s/g[2]/p[2]/ pg59: s/sc10/sc8.2.4/ s/new char/new char[0]/ twice pg64: s/*q++/(*q)++/ pg78: replace the first sentence in the second paragraph by: If both the second and the third expressions are of arithmetic type, then if they are of the same type the result is of that type; otherwise the usual arithmetic conversions are performed to bring them to a common type. Chapter 6: change T(*d)(double(3)); // expression-statement to T(*d)(double(3)); // declaration Chapter 7: pg98: 3rd non-commentary paragraph: add that `static' can be applied to anonymous unions. pg108: s/_dcl.fct.dcl_/sc8.2.5/ pg109: Replace ``The effect of any write operation on any part of such an object is undefined.'' by ``The effect of a write operation on any part of such an object is either an addressing exception or the same as if the object had been non-const.'' pg110: replace const pi = 22/7; by const pi = 3; // :-) pg111: s/qualified-typedef-name/qualified-type-name/ Chapter 8: pg139: s/except in default arguments(sc8.2.6// pg145: middle of page s/member function definition/nonstatic member function definition/ pg147: replace void another handler(const char*); by void another handler(const char* ...); p150: add to 4th noncommentary paragraph: So are members of static class objects. pg154: first example s/a, b/{ a, b }/ pg157: s/funct1/f1/ pg158: all cross references in sc8.1.2 should be to commentary sections: s/sc*/sc*c/ Chapter 9: last example initialize `p' by `new s;' pg174: last non-commentary paragraph, s/and 9.3// pg184: add to second paragraph An unnamed field is not a member and cannot be initialized. pg188: last paragraph s/enclosing function/enclosing scope/ twice pg189: second to last paragraph Type names obey exactly the same scope rules as other names. In particular, type names defined within a class declaration cannot be used outside their class without qualification. class X { public: typedef int I; class Y { /* ... */ }; I a; }; I b; // error Y c; // error X::Y d; // ok Chapter 10: pg196: s/sc4.6/sc4.7/ pg198: s/sc10.1/sc10.1c/ s/sc10.10/sc10.10c/ pg206: s/sc10.8/sc10.8c/ pg208: s/sc7.1.1/sc7.1.2/ pg209: s/sc7.1.1/sc7.1.2/ pg222: s/sc10.4/sc10.4c/ pg225: first paragraph s/`pa' and `pc'/`pb' and `pc'/ pg228: s/sc10.8/sc10.8c/ pg229: s/sc10.2/sc10.2c/ s/sc8.1.2/sc8.1.2c/ s/sc10.10/sc10.10c/ pg231: s/call-by-value/call-by-name/ pg232: 3rd paragraph s/nonvirtual member/non-inline virtual member/ pg235: The picture should look something like this: BW & BMW's vtbl: vptr ---------> &BW::f 0 BW part &MW::g delta(BW) &BMW::h 0 &W::k delta(W) MW's vtbl: vptr ---------> &BW::f -delta(MW) MW part &MW::g 0 &BMW::h -delta(MW) &W::K delta(W)-delta(MW) BMW part vptr ---------> W's vtbl: W part &BW::f -delta(W) &MW::g delta(MW)-delta(W) &BMW::H -delta(W) &W::k 0 pg237: Replace the page by: class LotterySimulation : public Lottery , public GraphicalObject { // ... virtual int l_draw() = Lottery::draw; virtual void go_draw() = GraphicalObject::draw; }; This would extend the pure virtual syntax in a natural manner. However, it was noted by Doug McIlroy that this problem does have a solution within \*C. Renaming can be achieved through the introduction of an extra class for each class with a virtual function that needs to be overridden by a function with a different name plus a forwarding function for each such function. For example: class LLottery : public Lottery { virtual int l_draw() = 0; int draw() // overrides Lottery::draw { return l_draw(); } }; class GGraphicalObject : public GraphicalObject { virtual int go_draw() = 0; void draw() // overrides GraphicalObject::draw { go_draw(); } }; class LotterySimulation : public LLottery , public GGraphicalObject { // ... int l_draw(); void go_draw(); }; Consequently, a language extension to express renaming is not necessary and is only worthwhile if the need to resolve such name clashes proves common. Chapter 12: pg270: s/sc12.1/sc12.1c/ s/sc12.2/sc12.2c/ Chapter 13: pg328: 2nd paragraph of commentary section: s/f()/g()/ Chapter 14: pg341: remove `Experimental' and the `Commentary' heading. (templates were voted into C++ by X3J11 in July 1990). pg343: last non-commentary paragraph /class members/static class members/ pg346 near bottom of page s/template-arg/template-argument/ s/template-arg-list/template-argument-list/ pg347 near top of page s/template-arg/template-argument/ pg351: last paragraph s/char*/char**/ twice Chapter 15: pg353: remove `Experimental' and the `Commentary' heading. (exceptions were voted into C++ by X3J11 in November 1990). pg357: first paragraph s/expression/object/ pg 359: first paragraph of 15.4: A handler with type `T' , `const T' , `T&' , or `const T&' is a match for a throw-expression with an object of type `E' if [1] `T' and `E' are the same type, or [2] `T' is an accessible (sc4.6) base class of `E' at the throw point, or [3] `T' is a pointer type and `E' is a pointer type that can be converted to `T' by a standard pointer conversion (sc4.6) at the throw point. pg 367: add 15.7 Exceptions and Access The formal argument of a catch clause obeys the same access rules as an argument of the function in which the catch clause occurs. An object may be thrown if it can be copied and destroyed in the context of the function in which the throw occurs. Commentary: Note that since a base class of a thrown object must be accessible, an object with two uses of a class as a base cannot be thrown unless both are virtual bases; otherwise the throw would be ambiguous. Note also that an object cannot be caught by a handler for a class that is a private base class of the object's class; a private class is considered an implementation detail. End commentary Chapter 16: pg380: s/(((/((/ Chapter 18: pg402: s/sc7.1.1/sc7.1.2/ Replace the line about void* by A pointer to any non-const and non-volatile object type can be assigned to a `void*'; sc4.6. This is also in ANSI C. A pointer to function can be assigned to a `void*'; sc4.6. pg404: s/enclosing the scope/enclosing the `struct'/. ----- End Included Message ----- ----- End Included Message ----- ----- End Included Message -----