comp.lang.ada
 help / color / mirror / Atom feed
From: Eric Hughes <eric.eh9@gmail.com>
Subject: Re: default formal parameters in generic declarations
Date: Tue, 4 Mar 2008 08:44:44 -0800 (PST)
Date: 2008-03-04T08:44:44-08:00	[thread overview]
Message-ID: <412874f9-9ddb-4aea-ac45-b366b0b1e68a@u10g2000prn.googlegroups.com> (raw)
In-Reply-To: u1w6sm11b.fsf@stephe-leake.org

Eric Hughes <eric....@gmail.com> 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 <stephen_le...@stephe-leake.org>
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




  parent reply	other threads:[~2008-03-04 16:44 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-02 17:21 default formal parameters in generic declarations Eric Hughes
2008-03-02 17:42 ` Robert A Duff
2008-03-02 19:40   ` Eric Hughes
2008-03-03  9:17     ` Dmitry A. Kazakov
2008-03-03 11:15       ` Georg Bauhaus
2008-03-03 13:56         ` Dmitry A. Kazakov
2008-03-04 16:15       ` Eric Hughes
2008-03-04  3:43     ` Randy Brukardt
2008-03-04 16:51       ` Eric Hughes
2008-03-04 18:43         ` Randy Brukardt
2008-03-05 21:08           ` Eric Hughes
2008-03-06  9:32             ` Georg Bauhaus
2008-03-06 18:05               ` Eric Hughes
2008-03-06 22:41                 ` Ludovic Brenta
2008-03-07 10:51                   ` Georg Bauhaus
2008-03-07 20:09                     ` Eric Hughes
2008-03-03 12:42 ` Stephen Leake
2008-03-04 13:50   ` Dr. Adrian Wrigley
2008-03-04 16:56     ` Eric Hughes
2008-03-04 16:44   ` Eric Hughes [this message]
2008-03-05 13:11     ` Stephen Leake
2008-03-05 21:41       ` Eric Hughes
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox