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,9d66743a9fdd96bd X-Google-Attributes: gid103376,public From: Stephen Leake Subject: Re: question about functions Date: 2000/01/24 Message-ID: #1/1 X-Deja-AN: 577028262 References: <867e3p$8ph$1@news.mgn.net> <3889A56C.61C4@nospam.com.tj> X-Complaints-To: dscoggin@cne-odin.gsfc.nasa.gov X-Trace: skates.gsfc.nasa.gov 948740329 11514 128.183.220.71 (24 Jan 2000 18:58:49 GMT) Organization: NASA Goddard Space Flight Center NNTP-Posting-Date: 24 Jan 2000 18:58:49 GMT Newsgroups: comp.lang.ada Date: 2000-01-24T18:58:49+00:00 List-Id: Andy writes: > Stephen Leake wrote: > > > > "Pascal LEJEUNE" writes: > > > [snipped] > > One alternate approach that is possible in Ada is to pass the result > > as an 'out' parameter : > > > > procedure f (A, B : in T; C : out T); > > > > now you can do C'Address. > > > But this would give the address of the formal parameter which > may not be the address of the actual parameter. Unless T is a > tagged type, isn't the compiler free pass parameters by > reference or value? It depends on why you are taking the address. In another post, you said you wanted to call a function implemented in assembly/hardware: Fast_Thing (A'address, B'address, C'address); If C is passed by copy, any changes 'Fast_Thing' makes to C will be copied back out to the "real" C when procedure 'f' returns. If C is passed by reference, 'Fast_Thing' operates directly on the "real" C. Either way, everyone is happy. The point is the compiler knows better than you whether copy or reference is better, and you don't have to care. On the other hand, if Fast_Thing needs to keep a copy of C'address for later use, then you have a problem. In that case, you should pass the address to 'f', not the object: procedure f (A, B : in T; C : access T); Use System.Address_To_Access_Conversions to reliably convert C to System.Address, independent of which compiler you are using. -- Stephe