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,8522260ffbf09d84 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-11-04 06:23:07 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Problem With Self-Referential Access-to-Subprogram Type Date: Tue, 04 Nov 2003 15:24:58 +0100 Message-ID: References: <80teqv099lspc5d4osf2gmu7cld46i0lvb@4ax.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: news.uni-berlin.de 1067955786 44513921 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:2040 Date: 2003-11-04T15:24:58+01:00 List-Id: On 4 Nov 2003 05:52:01 -0800, taashlo@cyberdude.com (Tad Ashlock) wrote: >Dmitry A. Kazakov wrote in message news:<80teqv099lspc5d4osf2gmu7cld46i0lvb@4ax.com>... >> On 3 Nov 2003 08:58:45 -0800, taashlo@cyberdude.com (Tad Ashlock) >> wrote: > >[snip] > >> > -- An access-to-procedure type that doesn't work: >> > type State2; >> > type State2 is access procedure (Tester : in out Test_Type'Class; >> > Resultant_State : out State2); >> > -- premature use of "State2" right here ^ >> >> type State2 is access procedure (Tester : in out Test_Type'Class; >> Resultant_State : access State2); > >Sure, but why should I have to? What is the difference between a >function return value and an "out" parameter that makes what I'm >trying to do an error for one but not the other? [...] >But my question above still stands. It appears that there is >something special about a function return value that can't be replaced >with a procedure "out" parameter. Yes, there is a difference. Technically, for an out parameter the compiler should still know the object constraints. Consider a case when the object be passed by value on the stack. State2 is being declared, so the compiler has no clue. Differently to an out parameter, a return value is unconstrained. For example you can: declare X : String := Get_Whatever_Length_I_Need; This does not work with out parameters. Because the compiler should anyway treat return values in a special way it is no matter whether its type is fully known. So the difference in general between outs and returns is. Though in your case there might actually be no difference (for types like access-to-subprogram). So theoretically one could drop this restriction for scalar, access types and some other types, but this would make the language too complex and its rules more difficult to understand. If Ada allowed 'Class for all types, as it IMO should, then you could write: type State2 is access procedure (Tester : in out Test_Type'Class; Resultant_State : in out State2'Class); with the desired effect. Unfortunately it does not allow this. --- Regards, Dmitry Kazakov www.dmitry-kazakov.de