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!attcan!uunet!seas.gwu.edu!mfeldman From: mfeldman@seas.gwu.edu (Michael Feldman) Newsgroups: comp.lang.ada Subject: Re: parameter passing Message-ID: <1986@sparko.gwu.edu> Date: 27 Jun 90 17:15:27 GMT References: <1569@oravax.UUCP> Reply-To: mfeldman@seas.gwu.edu () Organization: The George Washington University, Washington D.C. List-Id: In article <1569@oravax.UUCP> davidg@oravax.UUCP (David Guaspari) writes: >Certain kinds of reasoning about Ada subprograms that terminate by >raising exceptions are considerably simplified if one is allowed to >make the following assumption: > > If a and b are actual parameters to some call of subprogram P, > and a and b are of the same type, then that call passes them > in the same way (either both by copy or both by reference). Scalars are passed by copy - always. Structures and arrays can be passed by reference or by copy. I can speak for a few compilers I know (but don't remember which is which) - many systems will gauge which way to pass based on the size of the parameter. That is, arrays known to be "small" will be copied, but arrays not known to be small - either known to be large, or unconstrained and of unknown size - will be passed by reference. Since constrained objects of an unconstrained type have different subtypes but the same type, what you say holds true in my experience. I can't imagine why different objects of the same type should be passed differently. But then again, there are a lot of imaginable things _I_ can't imagine. Great question for language lawyers! --------------------------------------------------------------------------- Prof. Michael Feldman Department of Electrical Engineering and Computer Science The George Washington University Washington, DC 20052 +1-202-994-5253 mfeldman@seas.gwu.edu ---------------------------------------------------------------------------