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.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7251fa99aab97e06 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1993-03-25 14:29:52 PST Newsgroups: comp.lang.ada Path: sparky!uunet!europa.eng.gtefsd.com!gatech!usenet.ins.cwru.edu!agate!linus!linus.mitre.org!linus!mbunix!eachus From: eachus@dr_no.mitre.org (Robert I. Eachus) Subject: Re: Assignment Overload in Ada-9X In-Reply-To: beidler@guinness.cs.uofs.edu's message of 25 Mar 93 19:07:02 GMT Message-ID: Sender: news@linus.mitre.org (News Service) Nntp-Posting-Host: dr-no.mitre.org Organization: The Mitre Corp., Bedford, MA. References: <1993Mar19.222836.2540@evb.com> <11815@prijat.cs.uofs.edu> Date: Thu, 25 Mar 1993 22:29:52 GMT Date: 1993-03-25T22:29:52+00:00 List-Id: In article <11815@prijat.cs.uofs.edu> beidler@guinness.cs.uofs.edu (Jack Beidler) writes: > I recently received a copy of the "Ada 9X Project Report dated > February 1993. On the top of page 48 in this report there is a > statement about overloading assignment, specifically, > ".., in the case of non-limited control types, assignment > can be redefined by the user." > I curious about the form of the overload. Is it something like > procedure ":=" (Left : in out Some_Type ; Right : in Some_Type) ? > or have I misread this statement? No, it is not. And yes, you have misread the statement: control should be controlled, but that is a detail. The way it works is that there are three operations inherited by non-limited controlled types from the root type: INITIALIZE, FINALIZE and CLONE. (Well CLONE in ILS 1.2, I believe Tucker intends to change the name.) In any case, by redefining these operations when deriving from CONTROLLED, you can obtain the effect of modifying assignment. Of course, when defining these procedures, there are a lot of operations on the new type that will cause indefinite recursion, etc. But used properly, it allows for nice packaged abstractions where assignment does all the special things required. For example, it is (relatively) easy to define a reference-counting type or a general garbage collected type using this mechanism. Actually, now that this feature is relatively stable, I may post those examples for experts to shoot at. In either case it it about 20 lines of very sophisticated code that looks simple. It might even be a good idea to have both of these classes (oops! :-) as child packages in the standard. -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...