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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8e64f4db20d57eb5 X-Google-Attributes: gid103376,public From: jakrzy@ss2.magec.com (James A. Krzyzanowski) Subject: Re: Call by reference vs. call by value Date: 1996/07/20 Message-ID: #1/1 X-Deja-AN: 169117071 sender: usenet@most.fw.hac.com x-nntp-posting-host: ss2 references: <31F10E50.726@egr.uri.edu> organization: Magnavox Electronics Systems Company newsgroups: comp.lang.ada Date: 1996-07-20T00:00:00+00:00 List-Id: Christopher Felaco (felaco@egr.uri.edu) wrote: : I came across a problem with a procedure that resembled the following: : type Simple_Vector is array (1 .. 2) of Float; : procedure Vector_Manipulation (X : in Simple_Vector; : Y : out Simple_Vector) is : begin : Y (1) := X (1) + X (2); : Y (2) := X (1) * X (2); : end Vector_Manipulation; : I was told that calling this procedure with the same in and out : parameters as follows would give unexpected results: : Vector_Manipulation (X => Test_Vector, Y => Text_Vector); ^ Test_Vector I think you have a typo and meant that both actual parameters were the same variable. I just recently answered this exact question for a colleague. Here is a copy of my reply... I don't know if this is it, but check out LRM 6.2... paragraph (1) - "...The value of a variable is said to be updated when an assignment is performed to the variable, and also (indirectly) when the variable is used as actual parameter of a subprogram call...that updates its value" paragraph (7) - "...an implementation may achieve these effects by reference, that is, by arranging that every use of a formal parameter (to read or to update its value) be treated as a use of the associated actual parameter, throughout the execution of the subprogram call." Since the out parameter is the same variable as the in parameter, if the compiler writers chose to use "reference" for both the in and out parameter then the value of the in parameter would change everytime the out parameter changed. Sounds hokie but they could probably get away with it with the language referenced above. -- Not necessarily the opinion of the company... -- --------------------------------------------------------------------------- James A. Krzyzanowski - Senior Software Engineer - AFATDS Magnavox Electronic Systems Company * Fort Wayne, IN 46808 * (219) 429-6446 Internet: jakrzy@most.fw.hac.com * AOL: JimShiz@AOL.com * MOST: jakrzy@most "I'd rather be right than politically correct !!!" - Rush is Right ---------------------------------------------------------------------------