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,bed01d177eaef486 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.224.59.73 with SMTP id k9mr1589236qah.4.1343319646304; Thu, 26 Jul 2012 09:20:46 -0700 (PDT) Received: by 10.66.85.226 with SMTP id k2mr1491205paz.34.1343314456596; Thu, 26 Jul 2012 07:54:16 -0700 (PDT) Path: a15ni113198934qag.0!nntp.google.com!q21no13157082qas.0!news-out.google.com!b9ni64925521pbl.0!nntp.google.com!border1.nntp.dca.giganews.com!novia!news-peer1!btnet!zen.net.uk!hamilton.zen.co.uk!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!usenetcore.com!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.straub-nv.de!reality.xs3.de!nntp-feed.chiark.greenend.org.uk!ewrotcd!usenet-its.stanford.edu!usenet.stanford.edu!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Signature Package With Generic Proceedure Date: Sun, 22 Jul 2012 17:45:08 -0700 (PDT) Organization: http://groups.google.com Message-ID: <93f32ea9-a61d-4148-83be-258ae0676cac@googlegroups.com> References: <045f7b44-2a4a-4292-80fd-0b6bc8ee3465@googlegroups.com> <88734b25-68e5-42b2-89ea-0c0e3fc9fbc5@googlegroups.com> NNTP-Posting-Host: 68.4.246.214 Mime-Version: 1.0 X-Trace: posting.google.com 1343004408 32459 127.0.0.1 (23 Jul 2012 00:46:48 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 23 Jul 2012 00:46:48 +0000 (UTC) In-Reply-To: <88734b25-68e5-42b2-89ea-0c0e3fc9fbc5@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=68.4.246.214; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-07-22T17:45:08-07:00 List-Id: On Sunday, July 22, 2012 9:22:55 AM UTC-7, Keean Schupke wrote: >=20 > Why would you want to? Easy... You use signature packages to decouple the= =20 > implementation from the interface, so that other packages can decide whic= h > implementation to use. Well, "signatures" are hardly the only way to decouple things, and in pract= ice, of all the possible methods there are to decouple implementations from= interfaces, signature packages are probably the last method I would choose= . Do you come from some other language background where the "signature" co= ncept is more common? Whatever language that is, it sounds like the concep= t isn't as integral to Ada as it is in your other language. Because of tha= t, it took me a pretty long time to figure out what you were trying to acco= mplish. In fact, in the examples you provide, signatures seem completely unnecessar= y and confusing. You appear to have defined a package Disjointset_Signatur= e whose only generic formal is one type. Presumably, you then define gener= ic packages with formals like generic with package The_Signature is new Disjointset_Signature; procedure Algorithm (Set : in out The_Signature.Set_Type); But to me, this is a lot more confusing than just declaring generic type Set_Type is private; procedure Algorithm (Set : in out Set_Type); Generic signatures may have their uses, but I don't think they're all that = common in the Ada world. OK, with that rant out of the way: I think I finally figured out what you w= ere trying to do. You're trying to declare a generic procedure GP that is = parameterized with code from some other procedure P specified by the user, = but where P itself needs to be parameterized with another piece of code int= ernal to GP. And you'd like to do this in a way that allows everything to = be done inline, so that a compiler that performs macro-expansion when insta= ntiating generics (not all do) can generate a procedure Update that includ= es both code from P and code supplied by GP. That's an interesting concept, but it isn't supported by Ada, and I can't t= hink of a way to do it. Furthermore, since what you want can easily be acc= omplished (but not as efficiently) by access-to-procedures, I'm not sure th= at it's a good candidate for a new language feature. Sorry. You're probab= ly better off asking your compiler vendor for some implementation-defined p= ragmas to help with this (e.g. if the compiler knows, because of a pragma, = that Update will only be called with the 'Access of one known procedure, th= en the compiler could generate code that doesn't have to use indirect subpr= ogram calls and could inline the known procedure). -- Adam