comp.lang.ada
 help / color / mirror / Atom feed
From: Richard Riehle <richard@adaworks.com>
Subject: Re: Using "with function"
Date: Tue, 30 Oct 2001 23:00:50 -0800
Date: 2001-10-31T06:56:47+00:00	[thread overview]
Message-ID: <3BDFA1A2.EAF8B6AA@adaworks.com> (raw)
In-Reply-To: ttr5ves1r0m76@corp.supernews.com

Matthew Heaney wrote:

> Also, in general, you should use default notation for generic formal
> subprograms, like this:
>
> generic
>    type Element_Type is private;
>    with function "=" (L, R : Element_Type) return Boolean is <>;  --say "is
> box"
> package GP is

It is nice to hear from Matthew Heaney.  He has been absent for far too
long from this forum, and we always enjoy his comments.

I am going to respectfully disagree with Matthew on this.   While using the
"box" makes it easier to instantiate the "with function" it also carries with
it some danger.   Both Booch and Ed Berard made the case many years
ago for avoiding the use of operators directly in generic formal function
parameters.   In the GRACE components it was common to see somethin
like this:

     generic
        type Element_Type is private;
        with function Is_Equal(L, R : Element_Type) return Boolean;
     package GP ...

This has the effect of demanding that the instantiating unit supply a
generic actual parameter.

I recall a PhD thesis from Ohio State (apologize for forgetting the
author's name) in which the case was made for making all generic
formal parameters limited private and requiring the instantiation
to provide all kinds of operations, including a copy procedure
since assignment cannot be overloaded.

Of course, now that we can create generic signature packages in
Ada 95, that is packages that contain only generic formal parameters
for further instantiation of generic formal package parameters, the
Ohio State thesis gains a bit more credibility.

Richard Riehle





  parent reply	other threads:[~2001-10-31  7:00 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-20 15:56 Using "with function" Matt Raikes
2001-07-21  5:21 ` tmoran
2001-07-21 20:30 ` Mark Lundquist
2001-10-29 17:58 ` Matthew Heaney
2001-10-30 17:49   ` Mark Lundquist
2001-10-30 22:45     ` Steven Deller
2001-11-03  4:15       ` Mark Lundquist
2001-11-03  5:11         ` Computer Language Shootout Eric Merritt
2001-11-03  6:50           ` tmoran
2001-11-03  7:15             ` Al Christians
2001-11-03  8:52           ` martin.m.dowie
2001-11-03 14:04             ` Ted Dennison
2001-11-03 14:24               ` martin.m.dowie
2001-11-03 14:49               ` Larry Kilgallen
2001-11-03 23:03                 ` research@ijs.co.nz
2001-11-04  6:39                   ` tmoran
2001-11-04 13:44                     ` Larry Kilgallen
2001-11-05  0:59                       ` Adrian Hoe
2001-11-05  8:04                       ` David Brown
2001-11-06  6:36                     ` AG
2001-11-06  8:05                       ` tmoran
2001-11-07  8:58                         ` AG
2001-11-06 12:07                       ` Larry Kilgallen
2001-11-07  6:19                       ` Richard Riehle
2001-11-04 15:59             ` Preben Randhol
2001-11-04 20:04               ` martin.m.dowie
2001-10-31  7:00   ` Richard Riehle [this message]
2001-10-31 15:58     ` Using "with function" Matthew Heaney
replies disabled

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