comp.lang.ada
 help / color / mirror / Atom feed
From: scott@shuksan.UUCP (Scott Moody)
Subject: Re: converted types as actual in out parameters
Date: 20 Sep 88 16:05:30 GMT	[thread overview]
Message-ID: <894@shuksan.UUCP> (raw)
In-Reply-To: 8809151803.AA17461@ajpo.sei.cmu.edu

In article <8809151803.AA17461@ajpo.sei.cmu.edu>, GDAU100@BGUVM.BITNET ("Jonathan B. Owen") writes:
> The following worked for Vax-Ada but not for Verdix Ada.  Any thoughts?
>   a: short_integer;   pass    integer(a)  to an IN OUT routine ...

I tried this program on my sun v5.41 verdix compiler, and the result
was the same as you mentioned: 'Is this a Verdix Ada compiler?'

I then started thinking and wondering if that really was valid Ada, so
off to the LRM, page 6-8, sec 6.4.1, par 4:

"The variable name given for an actual parameter of mode in out or out is
evaluated before the call. If the actual parameter has the form of a type
conversion (Yes in this case), then before the call, for a parameter
of mode in out, the variable is CONVERTED to the specified type; 
after (normal) completion of the subprogram body, for a parameter of
mode in out or out, the formal parameter is CONVERTED BACK to the
type of the variable. (The type specified in the conversion must be that
of the formal parameter.)"

So the implementation should be something like:

   call_routine( integer(a))    

       ----- Translates to:

     declare
	tmp : integer;
     begin
	tmp :=  integer(a);
	call_routine(tmp);
	a   :=  short_integer(tmp);
     begin

     ------


Interesting! Something that is not obvious since most programming languages
would let the user convert to another type, but let them suffer when 
passing things by reference (more or less).

Unfortunately this seems to be the erroneous implementation Verdix chose.

-- scott @ Boeing Mountain Network

  reply	other threads:[~1988-09-20 16:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1988-09-17 11:18 converted types as actual in out parameters "Jonathan B. Owen"
1988-09-20 16:05 ` Scott Moody [this message]
1988-09-23 15:41 ` Burch Seymour
  -- strict thread matches above, loose matches on Subject: below --
1988-09-16 23:48 sboyd
replies disabled

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