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 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!u10g2000prn.googlegroups.com!not-for-mail From: Eric Hughes Newsgroups: comp.lang.ada Subject: Re: default formal parameters in generic declarations Date: Tue, 4 Mar 2008 08:44:44 -0800 (PST) Organization: http://groups.google.com Message-ID: <412874f9-9ddb-4aea-ac45-b366b0b1e68a@u10g2000prn.googlegroups.com> References: <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 1204649084 26688 127.0.0.1 (4 Mar 2008 16:44:44 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 4 Mar 2008 16:44:44 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: u10g2000prn.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:20182 Date: 2008-03-04T08:44:44-08:00 List-Id: Eric Hughes writes: > 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. On Mar 3, 5:42 am, Stephen Leake wrote: > I don't see why this would be "horribly klunky"; they typical user > will do: For a single package instantiation, a default formal package would have the same benefit as a default formal subprogram. It removes from a programmer's mind a detail that may not be relevant, and it removes from a less-experienced such mind a barrier to entry. I said "horribly klunky" specifically in reference to instantiation of aspects. The problem arises because, in general, an aspect _ought_ to have access to the internal state of the package for which it is acting as an aspect. That means that a base package requires an aspect parameter to instantiate it at the same time as the aspect requires a base package to instantiate it. The hard problem I had to figure out was how to avoid infinite regression. In C++, the solution was to rely upon a detail of template instantiation where a self- reference to a class itself with the template parameters of its instantiation refers _not_ to the templated base class but to the class being instantiated, and so thus creates (de facto) an anonymous type whose introduction breaks the regression. If that sounds complicated to understand, it is. The minimal syntax to declare and to instantiate is not simple. In fact, it's really quite a mess, and I couldn't figure out how to simplify it (even more-- I have some idea that it's minimal). Requiring an ordinary user to learn even some this detail simply to use the class in its ordinary way is a poor information-hiding practice. Eric