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-ArrivalTime: 2002-04-26 00:32:33 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Out parameters in a function Date: Fri, 26 Apr 2002 09:32:31 +0200 Message-ID: References: <4519e058.0204150709.55c94dfb@posting.google.com> <3cbbe583.3628858@news.demon.co.uk> <3cbc3f05.26543327@news.demon.co.uk> <3CC6E99F.3000603@home.com> 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 1019806351 9536538 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:23139 Date: 2002-04-26T09:32:31+02:00 List-Id: On Wed, 24 Apr 2002 17:21:37 GMT, "Warren W. Gay VE3WWG" wrote: >Dmitry A. Kazakov wrote: > >> On Tue, 16 Apr 2002 20:00:42 +0000 (UTC), "Kent Paul Dolan" >> wrote: > >... > >> Same in Ada: >> >> declare >> aSomestructTypedVariable : constant SomestructType := >> aSomestructReturningFunction (...); >> begin >> if aSomestructTypedVariable.booleanPart then >> usefulVal := aSomestructTypedVariable.usefulPart; >> end if; >> end; > >You could take this one step further (or perhaps this is implied) >and make the returned "SomestructType" a discriminated type. That >way if the value .booleanPart is false, the other member(s) of the >record/structure is invalid to access, maintaining safety. Yes, indeed. Safety is a good point. Ada offers many nice possibilities with that respect. Another is to return a class wide object with later dispatch on something like Use_That_Stuff. Regards, Dmitry Kazakov www.dmitry-kazakov.de