From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.7 required=5.0 tests=BAYES_00,FROM_WORDY, INVALID_DATE,T_FILL_THIS_FORM_SHORT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1ff5003422436e4 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-10-05 15:24:18 PST Path: bga.com!news.sprintlink.net!howland.reston.ans.net!math.ohio-state.edu!jussieu.fr!centre.univ-orleans.fr!univ-lyon1.fr!swidir.switch.ch!epflnews!dinews.epfl.ch!di.epfl.ch!Magnus.Kempe From: Magnus.Kempe@di.epfl.ch (Magnus Kempe) Newsgroups: comp.lang.ada Subject: Re: Easily-Read C++? Date: 5 Oct 1994 18:24:23 GMT Organization: Ecole Polytechnique Federale de Lausanne Distribution: world Message-ID: <1994Oct5.185354@di.epfl.ch> References: <941005030023_73672.2025_DHR103-1@CompuServe.COM> NNTP-Posting-Host: lglsun4.epfl.ch Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Date: 1994-10-05T18:24:23+00:00 List-Id: Ada was _designed_ to be readable. C++ is based on C, not something which was designed to be readable (to say the least). Is the code below readable? (pretty standard C++, no?) Try. Read it out, loud. -------------------------------------------------------------- template class Stack { public: Stack () {size = 0; head = 0;}; ~Stack () {if (head) delete head;}; void push (T& a); void pop (); T& top () {return head->item;}; int count () {return size;}; bool operation== (Stack& a); private: int size; Node *head; }; template class Node { public: Node (T6 a, Node *b): next(b), item(a) {}; ~Node () {if (next != 0) delete next;}; private: T item; Node *next; friend class stack; }; -------------------------------------------------------------- How does one pronounce "void push (T& a);", or "Node *b", or "{}" ? Do you notice the typos? Compare to a pretty standard Ada 9X equivalent: -------------------------------------------------------------- generic type Item_Type is private; package Stack_G is type Stack_Type is tagged limited private; procedure Push (Stack : in out Stack_Type; Item : in Item_Type); procedure Pop (Stack : in out Stack_Type); function Count (Stack : Stack_Type) return Natural; function Top (Stack : Stack_Type) return Item_Type; operator "=" (Left, Right : Stack_Type) return Boolean; private type Cell_Type; type Link_Type is access cell_Type; type Cell_Type is record Item : Item_Type; Next : Link_Type; end record; type Stack_Type is tagged limited record Size : Natural := 0; Head : Link_Type; end record; end Stack_G; -------------------------------------------------------------- Do you notice the typos? -- Magnus Kempe "I know not what course others may take, but as for me, Magnus.Kempe@di.epfl.ch Give me Liberty... or give me Death!" -- Patrick Henry