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.7 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!uunet!seas.gwu.edu!mfeldman From: mfeldman@seas.gwu.edu (Michael Feldman) Newsgroups: comp.lang.ada Subject: Re: ADA Compiling Query Keywords: Ada Message-ID: <2725@sparko.gwu.edu> Date: 14 Feb 91 16:45:36 GMT References: <5572@baird.cs.strath.ac.uk> <1991Feb13.211643.25777@rti.rti.org> Reply-To: mfeldman@seas.gwu.edu () Organization: The George Washington University, Washington D.C. List-Id: In article <1991Feb13.211643.25777@rti.rti.org> jb@rti.rti.org (Jeff Bartlett) writes: >In article <5572@baird.cs.strath.ac.uk>, gor@cs.strath.ac.uk (Gordon Russell) writes: > >See ANSI/MIL-STD-1815A section 6.2 paragraph 7: > > .... The language does not define which of these two mechanisms is to > be adopted for parameter passing, nor whether different calls to the > same subprogram are to use the same mechanism. The execution of a > program is erroneous if its effect depends on which mechanism is > selected by the implementation. > C'mon, guys - a little precision please. This applies only to _structured_ parameters. The preceding paragraph (6) states clearly that _scalars_ are copied. I've bumped into a lot of Pascal folks learning Ada who think that passing an array as IN OUT will magically get it passed by reference. This is a trick used in Pascal - you pass an array as VAR even if it is being used as an input parameter, because the _Pascal_ standard requires that it be copied otherwise. This sticks you in a bind in Pascal, because you've turned an input parameter into something your procedure may inadvertently modify. So you've traded speed for reliability. Too bad, but this is what Prof. Wirth wanted. (It's carried over to Modula-2 also). Carrying the Pascal trick over to Ada is futile and unnecessary. An IN parameter _cannot_ be modified; the compiler won't allow it. This permits the implementer to pass an array (yes, even as an IN parameter) by reference to save copying time and space. As I said in a previous posting, most implementers will pass by reference any structure large enough to be of concern. But if you think that using the Pascal trick - artificially making the array IN OUT to _guarantee_ that it'll be passed by reference - will work, guess again. Mike Feldman