comp.lang.ada
 help / color / mirror / Atom feed
From: Brian Rogoff <bpr@shell5.ba.best.com>
Subject: Re: Subverting 'Access for Sub-programs
Date: 1999/08/04
Date: 1999-08-04T00:00:00+00:00	[thread overview]
Message-ID: <Pine.BSF.4.10.9908042041540.29130-100000@shell5.ba.best.com> (raw)
In-Reply-To: 7o9vrv$qgt$1@wanadoo.fr

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: TEXT/PLAIN; charset=X-UNKNOWN, Size: 2670 bytes --]

On Wed, 4 Aug 1999, Jean-Pierre Rosen wrote:
> Anton Gibbs <agibbs@dera.gov.uk> a écrit dans le message :
> 37A7FDE8.4F5@dera.gov.uk...
> > Dear Ada Community,
> >
> > Thank you, everyone, for all the very helpful responses to my question
> > on 'Access.
> >
> > Unfortunately, in my eagerness to provide a simplified statement of my
> > problem, I had omitted an important detail: in fact, the procedure which
> > I called Main is really not the main program and, more importantly, it
> > has a parameter which I need to access.
> >
> [snip]
> I understood from a previous message that you didn't like the solution with
> a generic taking a formal procedure.
> It seems however that it would allow you to do precisely what you want.
> You may not "like" generics, but they are inherently safer than access
> values. Actually, in the discussion about downward closures, it was noted
> that all the cases presented could be equally well be dealt with with
> generics, and therefore that it was not worth introducing a risky feature.

Not true for any reasonable value of "equally well". For instance, in one
of those ancient postings of a few years ago on this very topic Richard
O'Keefe presented the example of making a two dimensional integrator from 
a one dimensional one. The Ada version with generics depended on the name
of the one dimensional integratoir, and so it was parameterized by that
particular integrator. The downward closure one was free to range over all 
one dimensional integrators. I'll append the code, if you can come up with
a perspicuous generic version that doesn't depend on the one dimensional
code I'll be more convinced. 

I think its also true that in the typical implementation of generics there 
will be a code size problem too. 

-- Brian

    type Func1_Type        is access function(X : Float) return Float;
    type Func2_Type        is access function(X,Y : Float) return Float;
    type Integrate_1D_Type is access function(X,Y : Float; 
					      F : Func1_Type) 
        return Float;

    function Integrate_1D(L1, U1 : Float;
			  F     :  Func1_Type) return Float is 
	-- some locals 
    begin
	-- some 1-D integrator 
    end;

    function Integrate_2D(L1, U1, L2, U2: Float;
			  Integrator : Integrate_1D_Type;
			  Func : Func2_Type ) return Float is 
	function Inner(Y: Float) return  Float is 
	    function Curried_F(X: Float) return Float is 
	    begin 
		return Func(X, Y) 
	    end;
	begin 
	    return Integrator(L1, U1, Curried_F'Unrestricted_Access) 
	end;
    begin 
	return Integrator(L2, U2, Inner'Unrestricted_Access) 
    end;






  reply	other threads:[~1999-08-04  0:00 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-03  0:00 Subverting 'Access for Sub-programs Anton Gibbs
1999-08-03  0:00 ` tmoran
1999-08-03  0:00 ` Steve Doiel
1999-08-03  0:00 ` Ted Dennison
1999-08-03  0:00 ` David C. Hoos, Sr.
1999-08-05  0:00   ` Robert A Duff
1999-08-03  0:00 ` Michael F. Yoder
1999-08-03  0:00 ` Brian Rogoff
1999-08-04  0:00 ` Robert Dewar
1999-08-04  0:00   ` Robert A Duff
1999-08-04  0:00     ` Robert Dewar
1999-08-04  0:00 ` Anton Gibbs
1999-08-04  0:00   ` Jean-Pierre Rosen
1999-08-04  0:00     ` Brian Rogoff [this message]
1999-08-05  0:00       ` Jean-Pierre Rosen
1999-08-05  0:00         ` Robert A Duff
1999-08-05  0:00           ` tmoran
1999-08-06  0:00             ` Robert A Duff
1999-08-05  0:00           ` Brian Rogoff
1999-08-06  0:00             ` Robert Dewar
1999-08-09  0:00               ` Tucker Taft
1999-08-10  0:00                 ` Robert Dewar
1999-08-11  0:00                   ` Dmitry A. Kazakov
1999-08-11  0:00                     ` Richard D Riehle
1999-08-11  0:00                     ` Robert Dewar
1999-08-12  0:00                       ` Dmitry A. Kazakov
1999-08-14  0:00                         ` Robert Dewar
1999-08-16  0:00                           ` Dmitry A. Kazakov
1999-08-11  0:00                   ` Robert A Duff
1999-08-11  0:00                     ` Robert Dewar
1999-08-11  0:00                   ` Tucker Taft
1999-08-13  0:00                     ` Robert Dewar
1999-08-13  0:00                       ` Brian Rogoff
1999-08-13  0:00                     ` Robert Dewar
1999-08-05  0:00           ` Robert Dewar
1999-08-05  0:00         ` adam
1999-08-05  0:00           ` Robert Dewar
1999-08-05  0:00             ` What is a Display ? (was: Subverting 'Access for Sub-programs) Larry Kilgallen
1999-08-05  0:00               ` Hyman Rosen
1999-08-06  0:00                 ` Robert Dewar
1999-08-06  0:00               ` Robert Dewar
1999-08-05  0:00           ` Subverting 'Access for Sub-programs adam
1999-08-06  0:00             ` Robert A Duff
1999-08-06  0:00               ` adam
1999-08-09  0:00                 ` Mark Biggar
1999-08-09  0:00                 ` Robert A Duff
1999-08-06  0:00         ` Brian Rogoff
1999-08-07  0:00           ` Gautier
1999-08-05  0:00     ` Robert A Duff
1999-08-05  0:00       ` Robert Dewar
1999-08-05  0:00         ` Brian Rogoff
1999-08-04  0:00   ` Robert A Duff
1999-08-04  0:00     ` Brian Rogoff
1999-08-05  0:00       ` tmoran
1999-08-05  0:00         ` Aidan Skinner
1999-08-05  0:00         ` Robert Dewar
1999-08-05  0:00           ` Ray Blaak
1999-08-06  0:00             ` Robert Dewar
1999-08-06  0:00               ` Robert A Duff
1999-08-08  0:00                 ` Brian Rogoff
1999-08-09  0:00                   ` Robert A Duff
1999-08-10  0:00                     ` Brian Rogoff
1999-08-09  0:00                 ` Tucker Taft
1999-08-06  0:00             ` Jean-Pierre Rosen
1999-08-06  0:00               ` Hyman Rosen
1999-08-07  0:00                 ` Florian Weimer
1999-08-05  0:00     ` Anton Gibbs
1999-08-05  0:00   ` Steve Quinlan
replies disabled

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