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,9464f7990925623f X-Google-Attributes: gid103376,public From: "Robert I. Eachus" Subject: Re: Attempting to modify a function result Date: 1999/07/22 Message-ID: <37976216.7454C725@mitre.org>#1/1 X-Deja-AN: 504096552 Content-Transfer-Encoding: 7bit References: <3797103C.4FD5@nospam.boeing.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.mitre.org X-Trace: top.mitre.org 932667744 27583 129.83.41.77 (22 Jul 1999 18:22:24 GMT) Organization: The MITRE Corporation Mime-Version: 1.0 NNTP-Posting-Date: 22 Jul 1999 18:22:24 GMT Newsgroups: comp.lang.ada Date: 1999-07-22T18:22:24+00:00 List-Id: "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...