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: 103376,8385fc6e4bf20336 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!s37g2000prg.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Generics with concrete and class-wide types Date: Tue, 1 Apr 2008 14:17:56 -0700 (PDT) Organization: http://groups.google.com Message-ID: <4d05402e-f953-4a75-91c1-8fccbcc2cd3e@s37g2000prg.googlegroups.com> References: <279b6f4f-36cf-446f-8b54-fd72b957b22f@i7g2000prf.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1207084676 27949 127.0.0.1 (1 Apr 2008 21:17:56 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 1 Apr 2008 21:17:56 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s37g2000prg.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:20742 Date: 2008-04-01T14:17:56-07:00 List-Id: On Apr 1, 1:10 pm, "Randy Brukardt" wrote: > "Adam Beneschan" wrote in message > > news:f0879dc0-7498-48f7-8d44-9856316d35ce@s19g2000prg.googlegroups.com... > ... > > > What's missing here is a way to specify a generic formal subprogram > > that must be a primitive operation of some tagged type (possibly a > > generic formal tagged type), > > No, it's not missing. That's what abstract formal subprograms are for. See > specifically 12.6(8.4-8.5/2). Ah ha, thank you! No, I didn't realize that's what they were for, perhaps because "abstract" isn't a synonym for "dispatching", but it makes sense now that you pointed me in the right direction. > I'm not sure that helps in this case, but feel free to try. ;-). I think it does help. If my previous example were changed to this: generic type Element is private; type Iterator_Root is tagged private; with function Get (I : in Iterator_Root) return Element is abstract <>; -- unspeakable syntax?? ... other operations package SP_For_Class is procedure Some_Procedure_Class (I : in Iterator_Root'Class); end SP_For_Class; with Some_Procedure; package body SP_For_Class is function Dispatching_Get (I : in Iterator_Root'Class) return Element is begin return Get (I); end Dispatching_Get; ... similarly for other operations procedure SP_Inst is new Some_Procedure (Element, Iterator_Root'Class, Dispatching_Get, ...other operations); procedure Some_Procedure_Class (I : in Iterator_Root'Class) renames SP_Inst; end SP_For_Class; then the call to Get inside Dispatching_Get would be legal. Then, in Maciej's case, if he wants a Some_Procedure instance that would work on a class-wide type and dispatch, he could instantiate SP_For_Class with the specific type, and then Some_Procedure_Class declared in the instance would be the procedure he's looking for. At least I think this would work---I haven't tried it. It's a little klunky to declare the SP_For_Class generic, but at least it wouldn't involve any duplicated code. And if it works, it will work without waiting for a solution to AI05-71. -- Adam