comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <dmitry@gandalf.atm.fh-luebeck.de>
Subject: Re: Subverting 'Access for Sub-programs
Date: 1999/08/16
Date: 1999-08-16T12:26:21+00:00	[thread overview]
Message-ID: <37B804C0.361F71EE@gandalf.atm.fh-luebeck.de> (raw)
In-Reply-To: 7p2n3g$us9$1@nnrp1.deja.com

Robert Dewar wrote:

> Passing something by reference is completely equivalent to
> passing it by pointer at the calling sequence level, and if
> you are calling a C program, it could not care whether you
> pass an array as an IN parameter, or pass a pointer to an
> array. The same is true of procedures. Passing a procedure
> by reference to foreign code would be identical to passing
> it by pointer.

Indeed but from implementation point of view only. From the
language point of view there is a great difference. Consider this:

   type PointerToInt is access all Integer;
   ExternalRef : PointerToInt;

   procedure Foo (X : Integer) is
   begin
      ExternalRef := X'access; -- Illegal!
   end Foo;
   procedure Foo (X : PointerToInt) is
   begin
      ExternalRef := X;           -- Legal!
   end Foo;

Further, the first version accepts all integer varaibles in all
contexts.
The second one:

   declare
       Temp : aliased Integer;
   begin
       Foo (Temp'access);   -- Illegal (for very good reason)
   end;

This is, I believe, exactly what we need for subprograms too.

> Yes, if you are only talking about ada-to-ada
> there is some protection (although I really think that the
> scheme proposed by the design team in mapping document 2
> is a lot neater, and you should review that thoroughly before
> making your own suggestions).

It is no matter which language is interfaced.

The interface (subprogram profile) should clarify whether
parameter (another subprogram) can be <'access>ed within
the callee or not. When you pass an object as-is, by reference
or by value, no matter (it is possible to imagine situation when
a subprogram is passed by copy (:-)), then its nesting is of no
importance. When you pass it by pointer, then you should
know what you do and all the limitations of 'access protect
unaware programmers (even if they do not want to be
protected (:-))

> But in practice call back programming VERY often involves
> interfacing to external code, in which case passing by
> reference vs passing by pointer is identical.

It always depends on WHAT the callee does. When you
create a modal dialog under Windows, the dialog procedure
can be passed by reference, for there is no return to caller
until dialog ends. It would work exactly identical to passing
by pointer with one great difference - without 'access (and
its unnecessary, in this case, limitations).

Best regards,
Dmitry





  reply	other threads:[~1999-08-16  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 ` Ted Dennison
1999-08-03  0:00 ` tmoran
1999-08-03  0:00 ` Steve Doiel
1999-08-03  0:00 ` Brian Rogoff
1999-08-03  0:00 ` Michael F. Yoder
1999-08-03  0:00 ` David C. Hoos, Sr.
1999-08-05  0:00   ` Robert A Duff
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
1999-08-05  0:00       ` Jean-Pierre Rosen
1999-08-05  0:00         ` Robert A Duff
1999-08-05  0:00           ` Robert Dewar
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                     ` 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 [this message]
1999-08-11  0:00                     ` Richard D Riehle
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-11  0:00                   ` Robert A Duff
1999-08-11  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                 ` Robert A Duff
1999-08-09  0:00                 ` Mark Biggar
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         ` 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         ` Aidan Skinner
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