From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!decwrl!ucbvax!NOSC-TECR.ARPA!CONTR22 From: CONTR22@NOSC-TECR.ARPA (Dale Gaumer) Newsgroups: comp.lang.ada Subject: Parameter modes Message-ID: <8811151407.AA10227@ajpo.sei.cmu.edu> Date: 15 Nov 88 13:05:37 GMT Sender: usenet@ucbvax.BERKELEY.EDU Organization: The Internet List-Id: 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