From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Extending A Generic Signature Package
Date: 1997/03/22
Date: 1997-03-22T00:00:00+00:00 [thread overview]
Message-ID: <E7G9zt.JxL@world.std.com> (raw)
In-Reply-To: 5gvgg0INNj32@snoopy.cis.ohio-state.edu
In article <5gvgg0INNj32@snoopy.cis.ohio-state.edu>,
david scott gibson <dgibson@snoopy.cis.ohio-state.edu> 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
next prev parent reply other threads:[~1997-03-22 0:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-03-17 0:00 Extending A Generic Signature Package david scott gibson
1997-03-18 0:00 ` Tucker Taft
1997-03-18 0:00 ` Alexander V. Konstantinou
1997-03-21 0:00 ` Geert Bosch
1997-03-21 0:00 ` Brian Rogoff
1997-03-22 0:00 ` Robert A Duff
1997-03-21 0:00 ` Jon S Anthony
1997-03-21 0:00 ` david scott gibson
1997-03-22 0:00 ` Robert A Duff
1997-03-22 0:00 ` Jon S Anthony
1997-03-21 0:00 ` david scott gibson
1997-03-22 0:00 ` Robert A Duff [this message]
1997-03-25 0:00 ` Jon S Anthony
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox