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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f4fd2,23202754c9ce78dd X-Google-Attributes: gidf4fd2,public X-Google-Thread: fac41,15edb893ef79e231 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,15edb893ef79e231 X-Google-Attributes: gid103376,public X-Google-Thread: 114809,15edb893ef79e231 X-Google-Attributes: gid114809,public X-Google-ArrivalTime: 2002-01-18 15:30:05 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.direct.ca!look.ca!newsfeed1.earthlink.net!newsfeed2.earthlink.net!newsfeed.earthlink.net!news.mindspring.net!not-for-mail From: Richard Riehle Newsgroups: comp.lang.lisp,comp.lang.ada,comp.lang.eiffel,comp.lang.smalltalk Subject: Re: True faiths ( was Re: The true faith ) Date: Fri, 18 Jan 2002 15:22:29 -0800 Organization: AdaWorks Software Engineering Message-ID: <3C48AE35.BA38ED04@adaworks.com> References: <%njZ7.279$iR.150960@news3.calgary.shaw.ca> <3c36fbc5_10@news.newsgroups.com> <4idg3u40ermnp682n6igc5gudp7hajkea9@4ax.com> <76be8851.0201101909.9db0718@posting.google.com> <9jtu3u8cq92b05j47uat3412tok6hqu1ki@4ax.com> <3C3F8689.377A9F0F@brising.com> <3219936759616091@naggum.net> <3C483CE7.D61D1BF@removeme.gst.com> <3C4863C5.6040406@mail.com> Reply-To: richard@adaworks.com NNTP-Posting-Host: 9e.fc.c5.c6 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Server-Date: 18 Jan 2002 23:29:18 GMT X-Mailer: Mozilla 4.7 [en] (Win98; I) X-Accept-Language: en Xref: archiver1.google.com comp.lang.lisp:24699 comp.lang.ada:19086 comp.lang.eiffel:5462 comp.lang.smalltalk:18187 Date: 2002-01-18T23:29:18+00:00 List-Id: Hyman Rosen wrote: > Bob Bane wrote: > > > I was particularly impressed with his last paragraph in the second > > article. For some reason, he doesn't conclude that there's something > > wrong with C++. Can't imagine why... > > I can. The problem he's trying to solve is difficult; I don't see > anything in its nature which wouldn't be equally difficult in Ada. Dijkstra said something once, I believe it was in "A Discipline of Computer Programming," about the inherent complexity of assignment and the fact that most programmers did not understand how it actually worked. In the same article, he suggests that, "until a programmer really understands assignment, he [sic] does not understand programming." In C++ or Ada (or whatever) there is no need to write an assignment operator unless the assignment between two objects is more complex than predefined assignment. One benefit of the limited type in Ada is to highlight the dangers of assignment. This is also why most complex data structures in Ada are limited types. I am not fond of the C++ idiom for tinkering with assignment, but it is a reasonable model given the rest of the language design. It is not clear Ada 95 got it right either, but it feels safer to me. I prefer Ada's proscription against directly overloading the assignment operator. The contract is more clear to me if it is written as, package P is type T is [tagged] limited private; -- no predefined methods on limited type -- public explicit declaration of methods on T procedure Copy_Deep (Source : in T; Target : in out T); procedure Copy_Shallow (Source : in T; Target : in out T); -- pre-conditions on Copy_Deep and Copy_Shallow Invalid_Source : exception; -- post-conditions on Copy_Deep and Copy_Shallow Incomplete_Copy_Operation : exception; private -- private methods, if any -- full definition of T; end P; This specification makes clear the contract and still eliminates any possibility for stupid assignment between objects of the type. Richard Riehle