comp.lang.ada
 help / color / mirror / Atom feed
From: Eric Hughes <eric.eh9@gmail.com>
Subject: default formal parameters in generic declarations
Date: Sun, 2 Mar 2008 09:21:05 -0800 (PST)
Date: 2008-03-02T09:21:05-08:00	[thread overview]
Message-ID: <9b3bac4d-5ae1-4a1b-a81e-9aa9ae1843e0@e31g2000hse.googlegroups.com> (raw)

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.



             reply	other threads:[~2008-03-02 17:21 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-02 17:21 Eric Hughes [this message]
2008-03-02 17:42 ` default formal parameters in generic declarations 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
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