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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,bed01d177eaef486 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.224.186.143 with SMTP id cs15mr1375903qab.3.1343316008534; Thu, 26 Jul 2012 08:20:08 -0700 (PDT) Received: by 10.66.80.168 with SMTP id s8mr1417285pax.28.1343315919786; Thu, 26 Jul 2012 08:18:39 -0700 (PDT) Path: a15ni113198934qag.0!nntp.google.com!q21no5086184qas.0!news-out.google.com!p10ni61947386pbh.1!nntp.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!novia!news-peer1!btnet!zen.net.uk!hamilton.zen.co.uk!xlned.com!feeder5.xlned.com!feed.xsnews.nl!border-1.ams.xsnews.nl!newsfeed.straub-nv.de!news.linkpendium.com!news.linkpendium.com!news.snarked.org!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Keean Schupke Newsgroups: comp.lang.ada Subject: Re: Signature Package With Generic Proceedure Date: Mon, 23 Jul 2012 11:29:01 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <045f7b44-2a4a-4292-80fd-0b6bc8ee3465@googlegroups.com> <88734b25-68e5-42b2-89ea-0c0e3fc9fbc5@googlegroups.com> <93f32ea9-a61d-4148-83be-258ae0676cac@googlegroups.com> <79925d0c-b2dd-44a3-9451-48f0ee19485f@googlegroups.com> <500d3a9d$0$6566$9b4e6d93@newsspool4.arcor-online.net> NNTP-Posting-Host: 82.44.19.199 Mime-Version: 1.0 X-Trace: posting.google.com 1343069734 18253 127.0.0.1 (23 Jul 2012 18:55:34 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 23 Jul 2012 18:55:34 +0000 (UTC) In-Reply-To: <500d3a9d$0$6566$9b4e6d93@newsspool4.arcor-online.net> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=82.44.19.199; posting-account=T5Z2vAoAAAB8ExE3yV3f56dVATtEMNcM User-Agent: G2/1.0 X-Received-Bytes: 3242 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-07-23T11:29:01-07:00 List-Id: On Monday, 23 July 2012 12:50:52 UTC+1, Georg Bauhaus wrote: > On 23.07.12 09:30, Keean Schupke wrote: > > Object oriented techniques all have considerable runtime costs due t= o using tagged types, and virtual functions (no inlining). >=20 > Nitpick: O-O in Ada would not necessarily preclude inlining, > since, by default, finding the primitive subprogram is > dynamic IFF there is dispatching (when 'Class is involved). >=20 > GNAT inlines OO.a and OO.b in clients of the following package > when the object of type T is specific: >=20 > package OO is > type T is tagged record > x : Natural; > end record; >=20 > function a (Object : T) return Natural; > function b (Object : T; off : Natural) return Natural; > pragma inline (a, b); > end OO; >=20 > package body OO is > function a (Object : T) return Natural is (Object.x); > function b (Object : T; off : Natural) return Natural is > begin > return natural'max (1000, Object.x + off); > end; > end OO; In the example you give surely the record does not need to be tagged at all= , in which case this is really just functions and types, no OO at all (and = would have been possible in Ada83?). Get rid of the tag, and then parameter= ise on the type of the object using generics... you can now reuse the same = code with different types of Objects. There is more to it than my bad descriptions. Look at type-classes in Haske= ll, google "datatype generic programming", and read Stepanov's "Elements of= Programming". Cheers, Keean.