From: "Robert I. Eachus" <eachus@mitre.org>
Subject: Re: Attempting to modify a function result
Date: 1999/07/22
Date: 1999-07-22T18:22:24+00:00 [thread overview]
Message-ID: <37976216.7454C725@mitre.org> (raw)
In-Reply-To: 3797103C.4FD5@nospam.boeing.com
"Raymond C. Rawa" wrote:
> I've encountered a "feature" of Ada83 or the VADS compiler that I don't
> understand.
It is a feature of Ada, not just VADS.
> ...Display.a := 5; -- I mean't to type: The_Display.a := 5;
Display is a function that returns an object of type Display_Type.
Display.a is a compontent of that object of type Integer, which gets
assigned the value 5. What is hard about that?
> The procedure Foo.Huh compiles and executes without error. As a side
> note, The_Display is unchanged by this procedure.
That probably means that the function is returning a copy of
The_Display. Some other implementation might return The_Display by
reference, in which case The_Display would be changed.
> Can someone please explain what's going on here?
A function call can be the prefix of an indexed or selected
component, or even a slice. In this case since Display has no
parameters, it surprised you.
(Actually I often use the construct of slicing the string returned by an
attribute: Put(Integer'Image(Foo)(2..Integer'Image(Foo)'Last); if I want
to drop the leading space.)
--
Robert I. Eachus
with Standard_Disclaimer;
use Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...
next prev parent reply other threads:[~1999-07-22 0:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-07-22 0:00 Attempting to modify a function result Raymond C. Rawa
1999-07-22 0:00 ` Pascal MALAISE
1999-07-23 0:00 ` Raymond C. Rawa
1999-07-22 0:00 ` Robert I. Eachus [this message]
1999-07-22 0:00 ` Keith Thompson
1999-07-23 0:00 ` John Herro
1999-07-26 0:00 ` Tucker Taft
1999-07-27 0:00 ` Ehud Lamm
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox