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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ce308a1d9e12d4fd,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-01-16 06:32:34 PST Path: supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.bu.edu!inmet!not-for-mail From: Tucker Taft Newsgroups: comp.lang.ada Subject: Re: Overloading the assignment operator Date: Tue, 16 Jan 2001 09:31:39 -0500 Organization: AverStar (formerly Intermetrics) Burlington, MA USA Message-ID: <3A645B4B.3BC177CE@averstar.com> References: <92vu8k$epg$1@news.vsnl.net.in> NNTP-Posting-Host: nebula.burl.averstar.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: inmet2.burl.averstar.com 979655499 22692 141.199.8.77 (16 Jan 2001 14:31:39 GMT) X-Complaints-To: usenet@inmet2.burl.averstar.com NNTP-Posting-Date: 16 Jan 2001 14:31:39 GMT X-Mailer: Mozilla 4.75 [en] (X11; U; SunOS 5.7 sun4u) X-Accept-Language: en Xref: supernews.google.com comp.lang.ada:4055 Date: 2001-01-16T14:31:39+00:00 List-Id: Shankar Narayanan wrote: > > Hello all! > > I'm new to ADA. I'm trying to implement a generic container > class for a stack which can hold different types of objects using > a generic type declaration of the form > > generic > type data_type is limited private; > > private > type node is record > data : data_type; > next : node_ptr; > end record; > > I'm using limited private types because they can be used with any > object (intrinsic or user-defined). The problem is that limited private > types do not support any of the standard operators (=, /= and :=). > While I've easily overloaded the = operator (and implicitly the /=), > I'm not quite able to overload the := (assignment) operator. > > Is it possible to overload the := operator. If so, how? Not directly, and not for limited types. You can of course define your own procedure "Assign" which may be adequate for most purposes. However, if you work with non-limited types, then you can make some or all of the type "controlled" by deriving it from Ada.Finalization.Controlled. If you override the "Adjust" and "Finalize" operation, you indirectly change the effect of an assignment. It's somewhat heavy going, so find a good Ada book, or stick with the simpler "Assign" procedure approach and limited types. > Thanks in advance > Shankar (shanxmail@yahoo.com) -- -Tucker Taft stt@avercom.net http://www.averstar.com/~stt/ Chief Technology Officer, AverCom, Inc. (A Titan Company) Burlington, MA USA (AverCom was formed 1/1/01 from the Commercial Division of AverStar) (http://www.averstar.com/services/ebusiness_applications.html)