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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,43f6bd9b498b66d0,start X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!e31g2000hse.googlegroups.com!not-for-mail From: Eric Hughes Newsgroups: comp.lang.ada Subject: default formal parameters in generic declarations Date: Sun, 2 Mar 2008 09:21:05 -0800 (PST) Organization: http://groups.google.com Message-ID: <9b3bac4d-5ae1-4a1b-a81e-9aa9ae1843e0@e31g2000hse.googlegroups.com> NNTP-Posting-Host: 166.70.57.218 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1204478465 19823 127.0.0.1 (2 Mar 2008 17:21:05 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 2 Mar 2008 17:21:05 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: e31g2000hse.googlegroups.com; posting-host=166.70.57.218; posting-account=5RIiTwoAAACt_Eu87gmPAJMoMTeMz-rn User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:20166 Date: 2008-03-02T09:21:05-08:00 List-Id: I've spent some time reading ARM2005/12. Generic Units. Formal objects and subprograms can have default values. Formal types and packages cannot. Could someone point me to the discussion where this inconsistency was decided to be a good thing? I have a certain sympathy with this absence with regard to packages, because Ada as yet has no expression for partial specification of packages, package derivation other than child packages, or (consequentially) a declaration "abstract package". The same, however, does not hold for types, not in the least. I have a couple of use cases where I'd like default values for formal packages. Not having them destroys concision. I can get something of the same effect by using separate names for the default and non- default cases and forwarding all the definitions with renaming statements and the like. This is error-prone and clunky. Here's one use case. Last year I had occasion to implement a certain fraction of aspect-oriented programming with C++ templates. (The restriction was that all cut-points have to be explicit.) An aspect is a separate class. It attaches to its underlying class as a generic (template) parameter when instantiating the underlying class. Each aspectable class also has a default aspect class, which is null. The null aspect is a default generic parameter. This means that a user need not be aware of the aspect at all (which is the ordinary case). In the non-generic case, the aspect contained code and state, instantiating the cut-points with augmented utility. I was using an aspect to do white-box unit testing on the inner behavior of a novel kind of scheduler. This facilities was critical to getting the system running right. And this all worked without the preprocessor. I would like to implement this in Ada, but the absence of a default package parameter means that instantiation is horribly clunky and that only the most dedicated would use it.