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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9245b8db9abd376c X-Google-Attributes: gid103376,public X-Google-Thread: 11232c,bde6489d2ec79329 X-Google-Attributes: gid11232c,public X-Google-ArrivalTime: 2002-04-17 00:57:28 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!130.133.1.3!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada,misc.misc Subject: Re: Out parameters in a function Date: Wed, 17 Apr 2002 09:57:26 +0200 Message-ID: References: <4519e058.0204150709.55c94dfb@posting.google.com> <3cbbe583.3628858@news.demon.co.uk> <3cbc3f05.26543327@news.demon.co.uk> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: fu-berlin.de 1019030246 3474275 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:22640 misc.misc:6446 Date: 2002-04-17T09:57:26+02:00 List-Id: On Tue, 16 Apr 2002 20:00:42 +0000 (UTC), "Kent Paul Dolan" wrote: >"John McCabe" wrote: > > > type of thing, but I can't remember off-hand how you would use a > > returned status with multiple return values! > >Well, if I'm not inventing capabilities, in C the syntax is fairly >direct (and forgive that with several dozen languages mixed in my head I >cannot write any one correctly without manual in lap, which I don't have >these days): > >if >( > ( > aSomestructTypedVariable = > aSomestructReturningFunction > ( > lots, > of, > parms > ) > ).booleanPart >) >{ > usefulVal = aSomestructTypedVariable.usefulPart; >} Same in Ada: declare aSomestructTypedVariable : constant SomestructType := aSomestructReturningFunction (...); begin if aSomestructTypedVariable.booleanPart then usefulVal := aSomestructTypedVariable.usefulPart; end if; end; Not a big deal. A real advantage [and possible the single one] of returned tuples of values is when you are able to use them as a part of the parameter list for some other subroutine. There are things that cannot be done with temp variables + out parameters. For instance Text :String := Get_Nobody_Knows_How_Many_Characters (...); cannot be replaced with: Text : String; -- Error! begin Get_Nobody_Knows_How_Many_Characters (..., Text); --- Regards, Dmitry Kazakov www.dmitry-kazakov.de