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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,5ebeef2944e4167d,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.180.106.199 with SMTP id gw7mr1060746wib.0.1346980966844; Thu, 06 Sep 2012 18:22:46 -0700 (PDT) Path: q11ni5513255wiw.1!nntp.google.com!feeder3.cambriumusenet.nl!feed.tweaknews.nl!85.12.40.130.MISMATCH!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!newsreader4.netcologne.de!news.netcologne.de!news.glorb.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: anonymous aggregates? Date: Fri, 31 Aug 2012 06:22:35 -0400 Message-ID: <85mx1bwec4.fsf@stephe-leake.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (windows-nt) Cancel-Lock: sha1:e1LslsG4B/5h/XPgjD28mkHwbgQ= MIME-Version: 1.0 X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: 702825040906ee029e66111605 X-Received-Bytes: 1896 Content-Type: text/plain Date: 2012-08-31T06:22:35-04:00 List-Id: Occasionally I have the following pattern: declare A : Integer; B : Float; procedure Foo (A : out Integer; B : out Float); begin Foo (A, B); ... end; where Foo initializes A, B. In general, I prefer to initialize variables in the declaration, and declare them constant if possible. But I can't do that here. One option in current Ada is to declare a record type; declare type Foo_Return_Type is record A : Integer; B : Float; end record; function Foo return Foo_Return_Type is begin return (A => 1, B => 2.0); end Foo; A_B : constant Foo_Return_Type := Foo; begin ... end; But that seems like overkill, especially since the code in "..." must be edited; all references to A must be replaced by A_B.A. If we introduce the notion of "anonymous aggregates" (styled after "anonymous arrays"), we could do this: declare function Foo return (A : Integer; B : Float) is begin return (A => 1, B => 2.0); end Foo; (A : constant integer, B : constant Float) := Foo; begin ... end; I haven't thought much about how this would be implemented. -- -- Stephe