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-05 09:49:06 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: adam@irvine.com (Adam Beneschan) Newsgroups: comp.lang.ada Subject: Re: Problem With Self-Referential Access-to-Subprogram Type Date: 5 Nov 2003 09:49:05 -0800 Organization: http://groups.google.com Message-ID: References: <80teqv099lspc5d4osf2gmu7cld46i0lvb@4ax.com> <20chqvglnrae8njr0011cfg3a8hc82je7m@4ax.com> NNTP-Posting-Host: 66.126.103.122 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1068054546 31017 127.0.0.1 (5 Nov 2003 17:49:06 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 5 Nov 2003 17:49:06 +0000 (UTC) Xref: archiver1.google.com comp.lang.ada:2094 Date: 2003-11-05T09:49:05-08:00 List-Id: Marius Amado Alves wrote in message news:... > On Wed, 2003-11-05 at 08:31, Dmitry A.Kazakov wrote: > > >> Yes, there is a difference. Technically, for an out parameter the > > >> compiler should still know the object constraints. > > > >Only at runtime. Consider Ada.Text_IO.Get (Item : out String). What > > >constraints is the compiler knowing here? > > > It knows that there are bounds which cannot be changed. If Item were > > of String (1..5) the compiler would probably choose another way of > > parameter passing than for String (<>) with the consequence that the > > stack frame would be different. > > Irrelevant. This applies to return types just as well. > > The original poster has a very good question--which has found no real > answer yet. My guess is it comes down to the hardware-orientedness of > Ada. I was surprised the *first* form compiled. It should not have compiled. 8.3(19) says that a declaration is hidden from all visibility until the end of the declaration, with some exceptions that don't apply here. So the type "State1" should not have been visible until *after* the semicolon following "return State1", and thus the compiler should have reported an error upon seeing "return State1". There is an Ada Issue (AI95-00313) suggesting that the rules be modified so that an access-to-subprogram type declaration can refer to itself anywhere after the word "access"; this would make the declarations of both State1 and State2 legal (and the incomplete type declarations wouldn't be necessary). The feeling at the time was that the additional work needed to change the language and the compilers shouldn't be required if no one has run into the problem in practice. I've let them know that someone now has run into it. -- Adam