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.3 required=5.0 tests=BAYES_00,INVALID_MSGID, 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 From: mark.biggar@trustedsyslabs.com Subject: Re: Constructors/Destructors in Ada95 Date: 2000/10/25 Message-ID: <8t6vhc$fmb$1@nnrp1.deja.com>#1/1 X-Deja-AN: 685705211 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> X-Http-Proxy: HTTP/1.1 sji-ca-cache[0A000001] (Traffic-Server/2.2 [uScMs f p eN:t cSMi p s ]), 1.0 x70.deja.com:80 (Squid/1.1.22) for client 165.236.189.200 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Wed Oct 25 15:51:11 2000 GMT X-MyDeja-Info: XMYDJUIDmark_biggar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.75 [en] (Win98; U) Date: 2000-10-25T00:00:00+00:00 List-Id: In article <8t6pi9$9s8$1@nnrp1.deja.com>, dmitry6243@my-deja.com wrote: > In article <39F6D201.73C006FA@acm.org>, > Marin David Condic wrote: > > Ray Blaak wrote: > > > > > I really would like to be able to do: > > > > > > procedure ":="(target : in out T; source : in T); > > > > > > so as to have complete control over what is happening. I vaguely recall some > > > rationale from the Ada 9X discussions for why user-defined assignment per se > > > was not incorporated. Does anyone remember? > > > > Does a > > statement like: "X < Y ;" make sense in Ada?) As a procedure, you'd have to allow > > procedures to have symbol names - which opens up a whole can of worms. Further, it > > would mean allowing "infix procedures" which is hard to make sense of - or at least > > could make programs look really strange. > > It would be nice (it is in my private Ada to-do list for a long time): > > function "*" (Left, Right : Matrix) return Matrix; -- Produces a new object > procedure "*" (Left : in out Matrix; Right : Matrix); -- Multiplies Left to > Right "in-place" > > So I would count it as an advantage. There is another. If you have > > procedure ":="(target : in out T; source : in T); > > then your assignment may take a look on the left-side object before its > destruction. Ada's Adjust is much more (IMO too much) specialized. > > > I'm sure there are dozens of other reasons why it was decided not to provide a > > means of letting the user define assignment. I'd think it would require perverting, > > warping and twisting language concepts too much. > > I think that the major reason was the decision to limit user defined > assigments by Controlled types. Doing so you must drop ":=" form, which > ontherwise would permanently remind you that actually all types might be > assigned (:-)) 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. There's a reason that C++ has several types of constructors and in many ways the Ada mechanism is simpler. -- Mark Biggar mark.biggar@trustedsyslabs.com Sent via Deja.com http://www.deja.com/ Before you buy.