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,4180a73b05d119c7 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-03-18 13:09:25 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newsfeed.news2me.com!cyclone1.gnilink.net!wn14feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!sccrnsc03.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: ML-like alternatives to out parameters for functions References: X-Newsreader: Tom's custom newsreader Message-ID: <7WLda.129634$eG2.17105@sccrnsc03> NNTP-Posting-Host: 12.234.13.56 X-Complaints-To: abuse@attbi.com X-Trace: sccrnsc03 1048021763 12.234.13.56 (Tue, 18 Mar 2003 21:09:23 GMT) NNTP-Posting-Date: Tue, 18 Mar 2003 21:09:23 GMT Organization: AT&T Broadband Date: Tue, 18 Mar 2003 21:09:24 GMT Xref: archiver1.google.com comp.lang.ada:35485 Date: 2003-03-18T21:09:24+00:00 List-Id: > Am I wrong to assume that the Ada-way is definitely to use the > discriminated return type, even in the case that Ada may get out Any time you have two variables which only make sense together but not separately, you have, conceptually, a single object. That can be modelled nicely in this case with a discriminated record. If you treat them as two separate things, there is always a significant danger of erroneously letting them get out of sync with each other. If profiling demonstrates that returning a discriminated record is too slow for the app, then it may be worth while to go to in-lining the calculation, separate variables, assembly language, etc.