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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d2f0af5e440b367f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-02 20:07:29 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!small1.nntp.aus1.giganews.com!nntp.giganews.com!cyclone1.gnilink.net!spamkiller2.gnilink.net!nwrdny02.gnilink.net.POSTED!53ab2750!not-for-mail From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5a) Gecko/20030611 Thunderbird/0.1a X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: proposal for new assignment operators References: <3EF9CD5F.6030608@cogeco.ca> <3doRhIgUmUYX@eisner.encompasserve.org> <3F038B77.2F2E41B7@adaworks.com> In-Reply-To: <3F038B77.2F2E41B7@adaworks.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Thu, 03 Jul 2003 03:07:28 GMT NNTP-Posting-Host: 162.83.152.221 X-Complaints-To: abuse@verizon.net X-Trace: nwrdny02.gnilink.net 1057201648 162.83.152.221 (Wed, 02 Jul 2003 23:07:28 EDT) NNTP-Posting-Date: Wed, 02 Jul 2003 23:07:28 EDT Xref: archiver1.google.com comp.lang.ada:40001 Date: 2003-07-03T03:07:28+00:00 List-Id: Richard Riehle wrote: > For limited types, assignment is never possible. Therefore, > overloading assignment is not possible. That "therefore" doesn't actually follow. In C++, to make assignment impossible, you declare a private assignment operator. Surely it would be no problem to say that assignment may not be overloaded for limited types. > It is rare that one even needs to override the assignment operator > on a non-limited type. There is a distinction here that will not > be immediately obvious to the C++ programmer. It's not that frequent to need to do it in C++ either, as long as you avoid low-level types such as pointers that are better handled by encapsulation in proper holder classes. Of course, in C++ you can define assignment between different types, and then you do find yourself writing assignment operators for describing that operation. For example, I might have a simple template struct ObjectHolder { T theObject; template ObjectHolder &operator=(const ObjectHolder &other) { theObject = other.theObject; return *this; } }; so that I can assign one kind of ObjectHolder to another. (This assignment will be legal only when the underlying types are assignment compatible, and will otherwise result in a compiler error message, so we are not decreasing type safety here.) > For a lot of very good reasons, the designers eschewed the C++ approach > in favor of the Adjust approach. These reasons are discussed in some of > the literature that covers the rationale for the language design. I looked at the section on Controlled types (7.4) in the Rationale and didn't see any discussion about this, except for a remark about returning limited types from functions. This leads me to believe that the "lot of very good reasons" have to do with technical aspects of preserving existing parts of Ada rather than abstract notions of how assignment should be done properly. Not that there's anything wrong with that.