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-Thread: a07f3367d7,5add429c86f59001 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!r37g2000yqd.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Ada vs Eiffel - Ada programmer approach Date: Thu, 4 Jun 2009 02:02:01 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <405b5054-4c8f-4e16-9ea8-503a9b9f976e@t21g2000yqi.googlegroups.com> <4A19765C.608@obry.net> <8105b65f-4de9-4653-b43a-d55ee33f072d@k2g2000yql.googlegroups.com> <9rWSl.118630$DP1.42605@attbi_s22> <02f8bbe8-b7fa-4633-bf90-1f2b9677264c@r34g2000vba.googlegroups.com> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1244106122 23681 127.0.0.1 (4 Jun 2009 09:02:02 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 4 Jun 2009 09:02:02 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: r37g2000yqd.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:6217 Date: 2009-06-04T02:02:01-07:00 List-Id: Yannick Duch=EAne wrote on comp.lang.ada: > On 26 mai, 20:21, "Jeffrey R. Carter" > > wrote: > > I agree. I never create tagged types, except to obtain finalization. I = think the > > widespread acceptance of programming by extension, even by People Who S= hould > > Know Better, represents the triumph of those who emphasize ease of writ= ing over > > ease of reading. > > So how do you do extentions ? > Did you never need this ? The question is not really "how do you do extension", but "why do you do extension". In my experience, composition is usually a more correct choice. There are, of course, some cases where extension is good but my inheritance hierarchies are usually very shallow. For example, if you want some record type T to become controlled, you don't have to make extend Ada.Finalization.Controlled; you don't even have to make T tagged. You can use a mixin instead: with Ada.Finalization; package P is type T is private; -- note: not publicly tagged private type Controller_T (Enclosing : access T) is new Ada.Finalization.Controlled with null record; overriding procedure Initialize (C : in out Controller); overriding procedure Adjust (C : in out Controller); overriding procedure Finalize (C : in out Controller); type T is record -- note: not privately tagged, either. Controller : Controller_T (Enclosing =3D> T'Access); -- other components... end record; end P; The primitive subprograms Initialize, Adjust and Finalize can see the entire enclosing object through the discriminant of C. -- Ludovic Brenta.