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,c1fe4bc1dd51fc87 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder3.cambrium.nl!feeder1.cambrium.nl!feed.tweaknews.nl!193.141.40.68.MISMATCH!npeer.de.kpn-eurorings.net!npeer-ng2.kpn.DE!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: User-defined type attributes Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <30f629fd-69d3-4d40-995f-9933f52b8dad@s37g2000prg.googlegroups.com> <965suhjl0bxt$.74se2ylyksin.dlg@40tude.net> Date: Fri, 14 Mar 2008 10:00:46 +0100 Message-ID: NNTP-Posting-Date: 14 Mar 2008 10:00:46 CET NNTP-Posting-Host: e2b19e5d.newsspool4.arcor-online.net X-Trace: DXC=3_3g>:_93N\\9P[:DUn00Q4IUK_lgb:EA\kJFR X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:20367 Date: 2008-03-14T10:00:46+01:00 List-Id: On Thu, 13 Mar 2008 20:46:41 -0500, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:965suhjl0bxt$.74se2ylyksin.dlg@40tude.net... > ... >> Why? The only thing you need is formal generic ADTs. Ada's generics lack >> ADTs, which is the reason why you need to pass operations together with the >> formal types. There exist formal built-in types like "private", "<>", >> "digits <>" etc, but there is no user-defined ones. Add these and all >> primitive operations will go with the actual type just per magic. It would >> be IMO a natural step for anybody who wanted generics to evolve in an >> Ada-way. (Not for me, as you know, I prefer generics removed from the >> language.) > > Generic formal derived types are the way to bring an ADT into a generic. > After all, they do bring in all of the primitive operations of the ADT. > > The only problem is that they can't be used on unrelated types, but that's > not very relevant if you are using tagged types (and you might as well being > doing so if you're defining any sort of composite type). Right, but this also implies that there is no need to have generics at all. A class-wide object does all what needed: generic type S is new T with private; procedure Foo (X : in out S); can be replaced by: procedure Foo (X : in out T'Class); -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de