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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ec2a500cce3658c4 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail From: Martin Krischik Newsgroups: comp.lang.ada Subject: Re: Memory leak - What the ...? Date: Thu, 14 Oct 2004 11:15:45 +0200 Organization: AdaCL Message-ID: <9998429.Mdq0TzxY3r@linux1.krischik.com> References: <416BAFA4.7020400@netcabo.pt> <1097675155.254329@master.nyc.kbcfp.com> Reply-To: krischik@users.sourceforge.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.t-online.com 1097745652 05 20838 jmlRXT8Lr-EtQGP 041014 09:20:52 X-Complaints-To: usenet-abuse@t-online.de X-ID: rYNc9UZYre3tC4d1-insz1rT2GPXzRX1lAtvElLXRrj7J1bzt4xCZY User-Agent: KNode/0.8.0 Xref: g2news1.google.com comp.lang.ada:5192 Date: 2004-10-14T11:15:45+02:00 List-Id: Hyman Rosen wrote: > Stephen Leake wrote: >> What would you consider "intuitive" in the area of Ada.Controlled? >> I suspect you actually mean "not like anything else I know". > > Most importantly, not like C++. Ada's model of breaking controlled > assignment into piecemeal function calls with a bit copy in the > middle is difficult to understand and deal with, as is the possibility > that Finalize may be called on an object multiple times, as is the > fact that Initialize isn't called on aggregates. In C++, for example, > user-defined assignment has access to both the object being assigned > and the object and value being assigned from. In Ada, if the identity > of the source object is important, I suppose you would have to finagle > something with access discriminants (but I don't know Ada, so I'm not > really sure). There is some advantage over C++ as well: It should render better performance on current CPU's and is saver. The reason is the all or nothing approach of C++. Either you use the build in bit copy constructor and assignment operator or you define you. 1st: block copys are faster on most CPUs then single assignments. 2nd: It is an easy mistake to forget the copy constructor or assignment operator when adding a new attribute. The copy constructor will then default initialise and assignment operator will keep the old value. And that is wrong behaviour in 99.9% of all cases. And please don't tell me you might *sometimes* want that behaviour. That is the precise point I just hate about C++: For the 0.1% change that you need some special behaviour the language accepts faulty code in cases where the compiler could actually find the bug for you. With Regards Martin -- mailto://krischik@users.sourceforge.net http://www.ada.krischik.com