comp.lang.ada
 help / color / mirror / Atom feed
From: CONTR22@NOSC-TECR.ARPA (Dale Gaumer)
Subject: Parameter modes
Date: 15 Nov 88 13:05:37 GMT	[thread overview]
Message-ID: <8811151407.AA10227@ajpo.sei.cmu.edu> (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

             reply	other threads:[~1988-11-15 13:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1988-11-15 13:05 Dale Gaumer [this message]
1988-11-18 14:06 ` Parameter modes Robert Firth
1988-11-21 23:46 ` Michael Murphy
  -- strict thread matches above, loose matches on Subject: below --
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
replies disabled

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