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,acb50cdf95d3e13c X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Extending A Generic Signature Package Date: 1997/03/22 Message-ID: #1/1 X-Deja-AN: 227532945 References: <5gkv23INN3rn@thalamus.cis.ohio-state.edu> <5guuehINN6iq@thalamus.cis.ohio-state.edu> <5gvgg0INNj32@snoopy.cis.ohio-state.edu> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 1997-03-22T00:00:00+00:00 List-Id: In article <5gvgg0INNj32@snoopy.cis.ohio-state.edu>, david scott gibson wrote: >Okay, I've primarily been using limited tagged types lately and forgot >that this rule only applied to them. Nevertheless, I assume compilers >may return tagged types, especially big ones, by reference. No, not unless the compiler can prove it makes no difference. E.g.: Global: T'Class := ...; function F return T'Class is begin return Global; end F; X: T'Class := F; ... Global.Component := 3; X and Global are not aliased. A copy must be made at the return statement. The assignment to a component of Global does not modify X. (The fact that the generated code might assume that F returns the address of the result in register R0 is irrelevant -- if that's what's going on, R0 will point to a *copy* of Global.) If T were limited, then F would return its result by reference, but then the above would be illegal, due to the ":= F". >... I didn't >mean to imply that objects passed by reference should be thought of as >"pointers". Ada seems to do a good job of making the mechanism >transparent. Parameter passing mechanism is not transparent in Ada -- you can tell the difference between by-ref and by-copy, and Ada allows either one (compiler's choice) in some cases. (I happen to think that's a flaw in the language. We've discussed it here before.) For function return, on the other hand, the language always requires by-ref or by-copy -- the choice is not up to the compiler. - Bob