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.7 required=5.0 tests=BAYES_00,MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b14a804025dceb20 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-10-27 02:00:07 PST Path: supernews.google.com!sn-xit-02!supernews.com!sienna.impulse.net!63.208.208.143.MISMATCH!feed2.onemain.com!feed1.onemain.com!xfer13.netnews.com!netnews.com!news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail From: dmitry6243@my-deja.com Newsgroups: comp.lang.ada Subject: Re: Constructors/Destructors in Ada95 Date: Fri, 27 Oct 2000 08:46:55 GMT Organization: Deja.com - Before you buy. Message-ID: <8tbfdv$601$1@nnrp1.deja.com> References: <39EE160D.F0A2000@bigfoot.com> <39EF5431.BF4CD793@bigfoot.com> <39F0A6C7.E592AFFB@averstar.com> <39F4AE95.4DB04145@bigfoot.com> <39F6D201.73C006FA@acm.org> <8t6pi9$9s8$1@nnrp1.deja.com> <8t6vhc$fmb$1@nnrp1.deja.com> <39F8A2CB.CA319F5@averstar.com> NNTP-Posting-Host: 212.79.192.251 X-Article-Creation-Date: Fri Oct 27 08:46:55 2000 GMT X-Http-User-Agent: Mozilla/4.75 [en] (WinNT; U) X-Http-Proxy: 1.0 x58.deja.com:80 (Squid/1.1.22) for client 212.79.192.251 X-MyDeja-Info: XMYDJUIDdmitry6243 Xref: supernews.google.com comp.lang.ada:1596 Date: 2000-10-27T08:46:55+00:00 List-Id: In article <39F8A2CB.CA319F5@averstar.com>, Tucker Taft wrote: > mark.biggar@trustedsyslabs.com wrote: > > ... > > > > One of the problems with this proposal (redefineing ":=") is that > > you would have to define Initialize, Adjust and Finialize anyway > > as you need them to implement value parameter passing, temporary > > creation and function return values correctly. Each of those is > > like assingment, but not exactly the same being, built out of the > > three primitives in different ways. So it makes more sense to just > > define the three primitives and have the compiler generate > > standard usage sequences then to redefine ":=" and have strange > > and hard to understand things happen. > > This is part of the reason we did not allow the user > to directly define ":=". Another important reason has to > do with assignment of composite objects (e.g. records > and arrays) containing objects with user-defined > assignment. One desirable feature is that the assignment > for a record, for example, is defined in terms of the > assignment of its individual components. Unfortunately, > there are cases of record assignment in Ada where > the left-hand-side doesn't contain a component that > the right-hand-side does. This happens if the left-hand-side > is an unconstrained record with discriminants, and the > right-hand-side happens to have different values for the > discriminants than the values of the left-hand-side. > As a result of the assignment, some components of the > left-hand-side may disappear, and some may come into existence. > > For example: > > type Rec(B : Boolean := False) is record > X : Cool_Controlled_Type; > case B is > when True => > Y : Fancy_Controlled_Type; > when False => > Z : Another_Controlled_Type; > end case; > end record; > > R1 : Rec; -- Defaults to B => False > R2 : Rec(B => True); > > ... > > R1 := R2; -- R1.Z disappears, R1.Y is created, > -- R1.X overwritten > > It would be tricky at best to define how or whether > user-defined ":=" for Cool_, Fancy_, and Another_Controlled_Type > should be used in the above case. [...] I think that an assumption that Adjust should be generated from user-defined ":=" is wrong, or at least very hard to implement. IMO, used-defined ":=" should have no special semantic. It is not an alternative to the copy constructor (= copy + Adjust). The single link between them is that the default ":=" is generated as Finalize, copy, Adjust. In the given example, the compiler should simply ignore ":=" defined for the types of Rec's components. Another question is, whether copy constructor should be splitted into block-copy and Adjust. -- Regards, Dmitry Kazakov Sent via Deja.com http://www.deja.com/ Before you buy.