comp.lang.ada
 help / color / mirror / Atom feed
* parameter modes
@ 2002-12-25 19:18 Jan
  2002-12-25 20:32 ` Jeffrey Creem
       [not found] ` <d0adua.hs3.ln@beastie.ix.netcom.com>
  0 siblings, 2 replies; 8+ messages in thread
From: Jan @ 2002-12-25 19:18 UTC (permalink / raw)


Hello.

Yet another question/problem:

I know how "in", "out", and "in out" works, so this is not the
problem, but I need to know what exactly happens in memory.
I need to pass a large array, so I need a parameter mode, which
doesn't make a copy of it.

This is what I found out (there is not much about it in the LRM, or
maybe I haven't found the right paragraph):

OUT : a 2nd variable of same type is made, containing undefined
      values. When procedure ends, this new variable is copied to the
      original one (and then the new one is probably removed from
      memory).

So now the question: what happens when using "IN" and "IN OUT"? I can
only guess, so I would be grateful when somebody (who really knows
what's behind it) could explain it to me.

BTW: I know that there can be also "ACCESS" (as a parameter mode),
could someone give an example? Maybe that's what I'm looking for (when
I want to pass an array).


Jan

---
eMail: janp9 @ gmx.net



^ permalink raw reply	[flat|nested] 8+ messages in thread
* Parameter modes
@ 1988-11-15 13:05 Dale Gaumer
  1988-11-18 14:06 ` Robert Firth
  1988-11-21 23:46 ` Michael Murphy
  0 siblings, 2 replies; 8+ messages in thread
From: Dale Gaumer @ 1988-11-15 13:05 UTC (permalink / raw)



     I would like to explore the possibility of using pass-by-reference for
non-scalar parameters with mode "out" or "in out". The LRM, in section 6.2(7),
states quite clearly that pass-by-copy is not required. However, the compilers
with which I am familiar use pass-by-copy. Since this is a serious performance
problem, I questioned several compiler vendors about why they chose to use
pass-by-copy.  The unanimous reply was, that the LRM requires pass-by-copy. 
     It was further explained to me that the LRM requires parameters to be
reset to the initial value when an exception occurs within the subprogram. And
the only way to ensure this result, is to use pass-by-copy. However the LRM,
in section 6.2(12), states that "the final value of an actual parameter of
such a type can be either its valued before the call or a value assigned to
the formal parameter during the execution of the subprogram". 
     A further explanation is that, an exception may occur during an
assignment of an array or record. If this were to occur, the assignment would
be incomplete. Therefore the result could contain garbage. If
pass-by-reference were used, this garbage would be returned as the actual
parameter. Therefore, since LRM 6.2(12) prohibits returning garbage as the
actual parameter, pass-by-copy must be used. However LRM section 5.2(3) states
that both sides of an assignment statement must be evaluated before the actual
assignment takes place. This would seems to preclude an exception occurring
during the actual assignment. 
     It seems to me that the LRM went to great lengths to make
pass-by-reference a legal implementation, for parameters of mode "out" or "in
out", which are array or record types. However this facility is not being used
by many compiler vendors. 


                                          David Brookman
                                          Magnavox Electronic Systems Company
                                          1313 Production Road
                                          Fort Wayne, IN 46808
                                          November 14, 1988

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2002-12-26 15:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-25 19:18 parameter modes Jan
2002-12-25 20:32 ` Jeffrey Creem
2002-12-26  0:03   ` Stapler
2002-12-26  0:09     ` Larry Kilgallen
     [not found] ` <d0adua.hs3.ln@beastie.ix.netcom.com>
2002-12-26 15:10   ` Jan
  -- strict thread matches above, loose matches on Subject: below --
1988-11-15 13:05 Parameter modes Dale Gaumer
1988-11-18 14:06 ` Robert Firth
1988-11-21 23:46 ` Michael Murphy

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