comp.lang.ada
 help / color / mirror / Atom feed
From: gor@cs.strath.ac.uk (Gordon Russell)
Subject: ADA Compiling Query
Date: 11 Feb 91 15:06:41 GMT	[thread overview]
Message-ID: <5572@baird.cs.strath.ac.uk> (raw)


 Hi out there, 
  I am hoping that someone on the network can answer a compiler implementation
problem for me. The problem stems from my PhD research into compiler 
techniques. If we consider the following program extract...


variable1 : integer;

procedure MAIN is
   variable1 : integer;
   result : integer;
----------------------------------------------------
 procedure GET_RESULT(variable2: in out integer) is
  begin
    variable1=2;
    variable2=variable1 + variable2;
  end GET_RESULT;
----------------------------------------------------
 begin
  variable1=10;
  get_result(variable1);
 end MAIN;

My question is.......what is variable1 equal to at the end of MAIN?
There appears to be a number of options....either
   (1) 4
   (2) 12
   (3) Something wierd
   (4) Compiler dependent.

Evidentally, it is reliant on whether GET_RESULT operates on variable2
directly or indirectly. I am hoping that the results are compiler 
dependent. Does anyone have an ADA compiler who is willing to test this?
I am especially interested to hear from official sources (if they are
reading this), since I do not want to break any validation suite
program.

Reply either to this newsgroup or by email. I will post a concensus if
comments are mailed directly to me. Please no flames if this program is
not syntatically correct, as it is the mechanism which I am inquiring 
after. And yes, I do think that this is poor programming practice,
but when has that stopped anyone!

Thanx in advance.....Gordon Russell
                     gor@cs.strath.ac.uk
[I would expect that a look at the standard would answer this question
quickly.  The issue of call by reference vs. call by copy in/copy out is at
least 30 years old.  Algol 60 inadvertently introduced call by name which
forced situations like this to compute the answer 4.  The various Fortran
standards have remained resolutely ambiguous, leaving the interpretation up
to the compiler writer.  The "in out" syntax suggests that copy in/copy out
is expected, but what the syntax suggests and what the standard says are of
course entirely different things. -John]
-- 
Send compilers articles to compilers@iecc.cambridge.ma.us or
{ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.

             reply	other threads:[~1991-02-11 15:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-02-11 15:06 Gordon Russell [this message]
1991-02-12 19:01 ` ADA Compiling Query Michael Feldman
1991-02-13 21:16 ` Jeff Bartlett
1991-02-14 16:45   ` Michael Feldman
1991-02-15 23:09     ` Jim Showalter
1991-02-17  0:19       ` Reference vs. copy semantics in passing parameters Michael Feldman
1991-02-17 18:54         ` Erland Sommarskog
1991-02-18 18:41           ` Doug Smith
1991-02-18  0:36         ` Jim Showalter
1991-02-18  1:42           ` Michael Feldman
1991-02-18 18:49           ` Arthur Evans
1991-02-19  2:05             ` Michael Feldman
1991-02-18 13:10         ` madmats
1991-02-19 19:00           ` Robert I. Eachus
1991-05-16 13:51         ` Alex Blakemore
1991-05-17  8:19           ` Matthias Ulrich Neeracher
1991-05-17 13:44           ` Markku Sakkinen
1991-05-28  5:28           ` Kenneth Almquist
1991-02-18 14:33 ` ADA Compiling Query stt
     [not found] <5572@baird.cs.strath.ac.uk#  <20600085@inmet>
1991-02-21 20:40 ` Michael Feldman
replies disabled

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