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 00:37:53 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.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: ML-like alternatives to out parameters for functions Date: Tue, 18 Mar 2003 09:37:51 +0100 Message-ID: <82md7v8cnp0g9aj2ibafnidcda8dufu057@4ax.com> References: 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 1047976671 74281994 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:35438 Date: 2003-03-18T09:37:51+01:00 List-Id: On 17 Mar 2003 23:17:12 +0100, Mark Lorenzen wrote: >There has lately been some discussions about Ada's missing >capabilities for specifying out parameters for functions. Apparently >this is a needed feature and an AI (AI-323) has been issued. > >An out parameter can be used when the validity of the result of >evaluating a function is not always well-defined. For example: [snip] >generic > type Value_Type is private; >package Optional_Value is [snip] > type Optional_Value_Type (Defined : Boolean := False) is > record > case Defined is > when True => > Value : Value_Type; > when False => > null; > end case; > end record; This won't work if Value_Type is unconstrained. The beauty of Ada's functions is that they are capable to return objects of unknown size, discriminants, specific type. Procedures lack this very important (especially when class-wide objects are concern) feature. So ether (1) functions should be allowed to have in-out parameters, or (2) procedures should be allowed to have a result. I prefer 2 and, maybe, a RM statement that an impure function is a bounded error. --- Regards, Dmitry Kazakov www.dmitry-kazakov.de