comp.lang.ada
 help / color / mirror / Atom feed
* Entries with Access Types as Formal Parameters
@ 1990-12-21 15:51 Greg Lomow
  0 siblings, 0 replies; only message in thread
From: Greg Lomow @ 1990-12-21 15:51 UTC (permalink / raw)



I have a question about Ada but unfortunately I don't have access
to an Ada compiler. Please forgive errors in the code example
that follows.

Consider a task with an entry that has a formal parameter of mode
"in out" which is an access type. Now consider a call to that
entry by another task where the actual parameter is an access
value that denotes a variable within the calling task. During the
execution of the accept statement the called task reads and
writes the variable denoted by the parameter.

Is the program well-defined? Or is it erroneous? If the program
is well-defined, what occurs at run-time? What if the program is
running on a distributed system and the two tasks are running on
different processors that do not have access to shared memory? If
you can, please cite references to the Ada Reference Manual.

------------------------------------------------------------

type int_access is access integer;

task a is 
  entry e(ia : in out int_access);
end;

task b;

------------------------------------------------------------

task body a is
  i : integer;
begin
  accept e(ia : int_access) do
    i := ia.all;
    ia.all := 20;
  end;
end;

task body b is
  ia : int_access;
begin
  ia := new integer(13);  
  a.e(ia);
end b;

------------------------------------------------------------
-- 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1990-12-21 15:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1990-12-21 15:51 Entries with Access Types as Formal Parameters Greg Lomow

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